Class TypeUtils

java.lang.Object
soot.jimple.infoflow.typing.TypeUtils

public class TypeUtils extends Object
Class containing various utility methods for dealing with type information
Author:
Steven Arzt
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static soot.Type
    buildArrayOrAddDimension(soot.Type type, soot.Type arrayType)
    Builds a new array of the given type if it is a base type or increments the dimensions of the given array by 1 otherwise.
    static boolean
    canStoreType(soot.FastHierarchy fh, soot.Type child, soot.Type parent)
    Checks whether a value of type "child" can be stored in a variable of type "parent".
    boolean
    checkCast(AccessPath accessPath, soot.Type type)
    Checks whether the type of the given taint can be cast to the given target type
    boolean
    checkCast(soot.Type destType, soot.Type sourceType)
    Checks whether the given source type can be cast to the given destination type
    static List<soot.SootClass>
    getAllDerivedClasses(soot.SootClass classOrInterface)
    Gets all classes that inherit from the given class or that transitively implement the given interface
    Gets the more precise one of the two given types
    soot.Type
    getMorePreciseType(soot.Type tp1, soot.Type tp2)
    Gets the more precise one of the two given types.
    static soot.Type
    Creates a Soot Type from the given string
    boolean
    hasCompatibleTypesForCall(AccessPath apBase, soot.SootClass dest)
     
    static boolean
    isObjectLikeType(soot.Type tp)
    Checks whether the given type is java.lang.Object, java.io.Serializable, or java.lang.Cloneable.
    static boolean
    isOverriden(soot.FastHierarchy fh, soot.MethodSubSignature originalSubSig, soot.SootMethod overriden)
    Checks whether "overriden" is an overriden version of "originalSubSig".
    boolean
    isOverriden(soot.MethodSubSignature originalSubSig, soot.SootMethod overriden)
    Checks whether "overriden" is an overriden version of "originalSubSig".
    static boolean
    isPrimitiveArray(soot.Type type)
     
    static boolean
    isStringType(soot.Type tp)
    Checks whether the given type is a string

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • isStringType

      public static boolean isStringType(soot.Type tp)
      Checks whether the given type is a string
      Parameters:
      tp - The type of check
      Returns:
      True if the given type is a string, otherwise false
    • isObjectLikeType

      public static boolean isObjectLikeType(soot.Type tp)
      Checks whether the given type is java.lang.Object, java.io.Serializable, or java.lang.Cloneable.
      Parameters:
      tp - The type to check
      Returns:
      True if the given type is one of the three "object-like" types, otherwise false
    • checkCast

      public boolean checkCast(soot.Type destType, soot.Type sourceType)
      Checks whether the given source type can be cast to the given destination type
      Parameters:
      destType - The destination type to which to cast
      sourceType - The source type from which to cast
      Returns:
      True if the given types are cast-compatible, otherwise false
    • checkCast

      public boolean checkCast(AccessPath accessPath, soot.Type type)
      Checks whether the type of the given taint can be cast to the given target type
      Parameters:
      accessPath - The access path of the taint to be cast
      type - The target type to which to cast the taint
      Returns:
      True if the cast is possible, otherwise false
    • isPrimitiveArray

      public static boolean isPrimitiveArray(soot.Type type)
    • hasCompatibleTypesForCall

      public boolean hasCompatibleTypesForCall(AccessPath apBase, soot.SootClass dest)
    • getMorePreciseType

      public soot.Type getMorePreciseType(soot.Type tp1, soot.Type tp2)
      Gets the more precise one of the two given types. If there is no ordering (i.e., the two types are not cast-compatible) null is returned.
      Parameters:
      tp1 - The first type
      tp2 - The second type
      Returns:
      The more precise one of the two given types
    • getMorePreciseType

      public String getMorePreciseType(String tp1, String tp2)
      Gets the more precise one of the two given types
      Parameters:
      tp1 - The first type
      tp2 - The second type
      Returns:
      The more precise one of the two given types
    • getTypeFromString

      public static soot.Type getTypeFromString(String type)
      Creates a Soot Type from the given string
      Parameters:
      type - A string representing a Soot type
      Returns:
      The Soot Type corresponding to the given string
    • buildArrayOrAddDimension

      public static soot.Type buildArrayOrAddDimension(soot.Type type, soot.Type arrayType)
      Builds a new array of the given type if it is a base type or increments the dimensions of the given array by 1 otherwise.
      Parameters:
      type - The base type or incoming array
      arrayType - The declared type of the array
      Returns:
      The resulting array
    • getAllDerivedClasses

      public static List<soot.SootClass> getAllDerivedClasses(soot.SootClass classOrInterface)
      Gets all classes that inherit from the given class or that transitively implement the given interface
      Parameters:
      classOrInterface - The class or interface for which to enumerate the derived classes
      Returns:
      The classes derived from the given class or interface
    • canStoreType

      public static boolean canStoreType(soot.FastHierarchy fh, soot.Type child, soot.Type parent)
      Checks whether a value of type "child" can be stored in a variable of type "parent". If one of the types is null, we assume that the value cannot be stored.
      Parameters:
      fh - The FastHierarchy
      child - The actual type of the value
      parent - The declared type of the variable
      Returns:
      True if a value of type "child" can be stored in a variable of type "parent", false otherwise
    • isOverriden

      public static boolean isOverriden(soot.FastHierarchy fh, soot.MethodSubSignature originalSubSig, soot.SootMethod overriden)
      Checks whether "overriden" is an overriden version of "originalSubSig". We have to check for covariance of the return value and the contra variance of all parameters
      Parameters:
      fh - The FastHierarchy
      originalSubSig - The sub signature of the base method
      overriden - The potentially method overriding the method of "originalSubSig"
      Returns:
      true if "overriden" overrides "originalSubSig"
    • isOverriden

      public boolean isOverriden(soot.MethodSubSignature originalSubSig, soot.SootMethod overriden)
      Checks whether "overriden" is an overriden version of "originalSubSig". We have to check for covariance of the return value and the contra variance of all parameters
      Parameters:
      originalSubSig - The sub signature of the base method
      overriden - The potentially method overriding the method of "originalSubSig"
      Returns:
      true if "overriden" overrides "originalSubSig"