Package soot.jimple.infoflow.typing
Class TypeUtils
java.lang.Object
soot.jimple.infoflow.typing.TypeUtils
Class containing various utility methods for dealing with type information
- Author:
- Steven Arzt
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic soot.TypebuildArrayOrAddDimension(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 booleancanStoreType(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".booleancheckCast(AccessPath accessPath, soot.Type type) Checks whether the type of the given taint can be cast to the given target typebooleancheckCast(soot.Type destType, soot.Type sourceType) Checks whether the given source type can be cast to the given destination typestatic List<soot.SootClass>getAllDerivedClasses(soot.SootClass classOrInterface) Gets all classes that inherit from the given class or that transitively implement the given interfacegetMorePreciseType(String tp1, String tp2) Gets the more precise one of the two given typessoot.TypegetMorePreciseType(soot.Type tp1, soot.Type tp2) Gets the more precise one of the two given types.static soot.TypegetTypeFromString(String type) Creates a Soot Type from the given stringbooleanhasCompatibleTypesForCall(AccessPath apBase, soot.SootClass dest) static booleanisObjectLikeType(soot.Type tp) Checks whether the given type is java.lang.Object, java.io.Serializable, or java.lang.Cloneable.static booleanisOverriden(soot.FastHierarchy fh, soot.MethodSubSignature originalSubSig, soot.SootMethod overriden) Checks whether "overriden" is an overriden version of "originalSubSig".booleanisOverriden(soot.MethodSubSignature originalSubSig, soot.SootMethod overriden) Checks whether "overriden" is an overriden version of "originalSubSig".static booleanisPrimitiveArray(soot.Type type) static booleanisStringType(soot.Type tp) Checks whether the given type is a string
-
Constructor Details
-
TypeUtils
-
-
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 castsourceType- The source type from which to cast- Returns:
- True if the given types are cast-compatible, otherwise false
-
checkCast
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 casttype- 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
-
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 typetp2- The second type- Returns:
- The more precise one of the two given types
-
getMorePreciseType
Gets the more precise one of the two given types- Parameters:
tp1- The first typetp2- The second type- Returns:
- The more precise one of the two given types
-
getTypeFromString
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 arrayarrayType- The declared type of the array- Returns:
- The resulting array
-
getAllDerivedClasses
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 isnull, we assume that the value cannot be stored.- Parameters:
fh- TheFastHierarchychild- The actual type of the valueparent- 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- TheFastHierarchyoriginalSubSig- The sub signature of the base methodoverriden- 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 methodoverriden- The potentially method overriding the method of "originalSubSig"- Returns:
- true if "overriden" overrides "originalSubSig"
-