Package soot
Class SootClass
- java.lang.Object
-
- soot.tagkit.AbstractHost
-
- soot.SootClass
-
- All Implemented Interfaces:
Host
- Direct Known Subclasses:
SootModuleInfo
public class SootClass extends AbstractHost
Soot representation of a Java class. They are usually created by a Scene, but can also be constructed manually through the given constructors.
-
-
Field Summary
Fields Modifier and Type Field Description static intBODIESstatic intDANGLINGprotected Chain<SootField>fieldsprotected StringfixedPackageNameprotected StringfixedShortNamestatic intHIERARCHYprotected Chain<SootClass>interfacesstatic StringINVOKEDYNAMIC_DUMMY_CLASS_NAMEprotected booleanisInSceneprotected booleanisPhantomprotected List<SootMethod>methodListprotected intmodifiersprotected SootModuleInfomoduleInformationStringmoduleNameprotected Stringnameprotected intnumberprotected SootClassouterClassprotected StringpackageNameprotected StringshortNamestatic intSIGNATURESprotected SmallNumberedMap<NumberedString,SootMethod>subSigToMethodsprotected SootClasssuperClass-
Fields inherited from class soot.tagkit.AbstractHost
col, line, mTagList
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddField(SootField f)Adds the given field to this class.voidaddInterface(SootClass interfaceClass)Add the given class to the list of interfaces which are directly implemented by this class.voidaddMethod(SootMethod m)Adds the given method to this class.voidcheckLevel(int level)Checks if the class has at least the resolving level specified.voidcheckLevelIgnoreResolving(int level)Checks if the class has at least the resolving level specified.booleancontainsBafBody()Returns true if some method in this class has an active Baf body.booleandeclaresField(String subsignature)Does this class declare a field with the given subsignature?booleandeclaresField(String name, Type type)Does this class declare a field with the given name and type.booleandeclaresFieldByName(String name)Does this class declare a field with the given name?booleandeclaresMethod(String subsignature)Does this class declare a method with the given subsignature?booleandeclaresMethod(String name, List<Type> parameterTypes)Does this class declare a method with the given name and parameter types?booleandeclaresMethod(String name, List<Type> parameterTypes, Type returnType)Does this class declare a method with the given name, parameter types, and return type?booleandeclaresMethod(NumberedString subsignature)Does this class declare a method with the given subsignature?booleandeclaresMethodByName(String name)Does this class declare a method with the given name?SootFieldgetField(String subsignature)Returns the field of this class with the given subsignature.SootFieldgetField(String name, Type type)Returns the field of this class with the given name and type.SootFieldgetFieldByName(String name)Returns the field of this class with the given name.SootFieldgetFieldByNameUnsafe(String name)Returns the field of this class with the given name.intgetFieldCount()Returns the number of fields in this class.Chain<SootField>getFields()Returns a backed Chain of fields.SootFieldgetFieldUnsafe(String subsignature)Returns the field of this class with the given subsignature.SootFieldgetFieldUnsafe(String name, Type type)Returns the field of this class with the given name and type.StringgetFilePath()intgetInterfaceCount()Returns the number of interfaces being directly implemented by this class.Chain<SootClass>getInterfaces()Returns a backed Chain of the interfaces that are directly implemented by this class.StringgetJavaPackageName()StringgetJavaStyleName()SootMethodgetMethod(String subsignature)SootMethodgetMethod(String name, List<Type> parameterTypes)Attempts to retrieve the method with the given name and parameters.SootMethodgetMethod(String name, List<Type> parameterTypes, Type returnType)Attempts to retrieve the method with the given name, parameters and return type.SootMethodgetMethod(NumberedString subsignature)Returns the method of this class with the given subsignature.SootMethodgetMethodByName(String name)Attempts to retrieve the method with the given name.SootMethodgetMethodByNameUnsafe(String name)Attempts to retrieve the method with the given name.intgetMethodCount()Returns the number of methods in this class.List<SootMethod>getMethods()Collection<SootMethod>getMethodsByNameAndParamCount(String name, int paramCount)Returns all methods with exactly the number of parameters specified.SootMethodgetMethodUnsafe(String subsignature)SootMethodgetMethodUnsafe(String name, List<Type> parameterTypes, Type returnType)Attempts to retrieve the method with the given name, parameters and return type.SootMethodgetMethodUnsafe(NumberedString subsignature)Returns the method of this class with the given subsignature.intgetModifiers()Returns the modifiers of this class.SootModuleInfogetModuleInformation()StringgetName()Returns the name of this class.SootFieldgetOrAddField(SootField f)SootMethodgetOrAddMethod(SootMethod m)SootClassgetOuterClass()SootClassgetOuterClassUnsafe()This method returns the outer class, or null if no outer class has been specified for this class.StringgetPackageName()Returns the package name of this class.StringgetShortJavaStyleName()StringgetShortName()SootClassgetSuperclass()WARNING: interfaces are subclasses of the java.lang.Object class! Returns the superclass of this class.SootClassgetSuperclassUnsafe()This method returns the superclass, or null if no superclass has been specified for this class.RefTypegetType()Returns the RefType corresponding to this class.booleanhasOuterClass()booleanhasRefType()booleanhasSuperclass()WARNING: interfaces are subclasses of the java.lang.Object class! Does this class have a superclass? False implies that this is the java.lang.Object class.booleanimplementsInterface(String name)Does this class directly implement the given interface? (see getInterfaceCount())protected voidinitializeRefType(String name, String moduleName)Makes sure that there is a RefType pointing to this SootClass.booleanisAbstract()Convenience method returning true if this class is abstract.booleanisApplicationClass()Convenience method returning true if this class is an application class.booleanisConcrete()Returns true if this class is not an interface and not abstract.booleanisEnum()Convenience method; returns true if this class is an enumeration.booleanisExportedByModule()Checks if this class is exported by it's modulebooleanisExportedByModule(String toModule)Checks if this class is exported by it's modulebooleanisFinal()Convenience method returning true if this class is final.booleanisInnerClass()booleanisInScene()booleanisInterface()Convenience method; returns true if this class is an interface.booleanisJavaLibraryClass()Sometimes we need to know which class is a JDK class.booleanisLibraryClass()Convenience method returning true if this class is a library class.booleanisOpenedByModule()booleanisPhantom()Convenience method returning true if this class is phantom.booleanisPhantomClass()Convenience method returning true if this class is a phantom class.booleanisPrivate()Convenience method returning true if this class is private.booleanisProtected()Convenience method returning true if this class is protected.booleanisPublic()Convenience method; returns true if this class is public.booleanisStatic()Convenience method returning true if this class is static.booleanisSynchronized()Convenience method; returns true if this class is synchronized.protected static StringlevelToString(int level)Iterator<SootMethod>methodIterator()Returns an iterator over the methods in this class.voidremoveField(SootField f)Removes the given field from this class.voidremoveInterface(SootClass interfaceClass)Removes the given class from the list of interfaces which are directly implemented by this class.voidremoveMethod(SootMethod m)Removes the given method from this class.voidrename(String newName)voidrenameFieldsAndMethods(boolean privateOnly)Renames private fields and methods with numeric names.intresolvingLevel()voidsetApplicationClass()Makes this class an application class.voidsetInScene(boolean isInScene)Tells this class if it is being managed by a Scene.voidsetLibraryClass()Makes this class a library class.voidsetModifiers(int modifiers)Sets the modifiers for this class.voidsetModuleInformation(SootModuleInfo moduleInformation)voidsetName(String name)Sets the name of this class.voidsetOuterClass(SootClass c)voidsetPhantomClass()Makes this class a phantom class.voidsetRefType(RefType refType)voidsetResolvingLevel(int newLevel)voidsetSuperclass(SootClass c)Sets the superclass of this class.StringtoString()Returns the name of this class.voidvalidate()Validates this SootClass for logical errors.voidvalidate(List<ValidationException> exceptionList)Validates this SootClass for logical errors.-
Methods inherited from class soot.tagkit.AbstractHost
addAllTagsOf, addTag, getJavaSourceStartColumnNumber, getJavaSourceStartLineNumber, getTag, getTags, hasTag, removeAllTags, removeTag
-
-
-
-
Field Detail
-
INVOKEDYNAMIC_DUMMY_CLASS_NAME
public static final String INVOKEDYNAMIC_DUMMY_CLASS_NAME
- See Also:
- Constant Field Values
-
DANGLING
public static final int DANGLING
- See Also:
- Constant Field Values
-
HIERARCHY
public static final int HIERARCHY
- See Also:
- Constant Field Values
-
SIGNATURES
public static final int SIGNATURES
- See Also:
- Constant Field Values
-
BODIES
public static final int BODIES
- See Also:
- Constant Field Values
-
name
protected String name
-
shortName
protected String shortName
-
fixedShortName
protected String fixedShortName
-
packageName
protected String packageName
-
fixedPackageName
protected String fixedPackageName
-
modifiers
protected int modifiers
-
subSigToMethods
protected SmallNumberedMap<NumberedString,SootMethod> subSigToMethods
-
methodList
protected List<SootMethod> methodList
-
isInScene
protected boolean isInScene
-
superClass
protected SootClass superClass
-
outerClass
protected SootClass outerClass
-
isPhantom
protected boolean isPhantom
-
moduleName
public final String moduleName
-
moduleInformation
protected SootModuleInfo moduleInformation
-
number
protected volatile int number
-
-
Method Detail
-
initializeRefType
protected void initializeRefType(String name, String moduleName)
Makes sure that there is a RefType pointing to this SootClass. Client code that provides its own SootClass implementation can override and modify this behavior.- Parameters:
name- The name of the new class
-
levelToString
protected static String levelToString(int level)
-
checkLevel
public void checkLevel(int level)
Checks if the class has at least the resolving level specified. This check does nothing is the class resolution process is not completed.- Parameters:
level- the resolution level, one of DANGLING, HIERARCHY, SIGNATURES, and BODIES- Throws:
RuntimeException- if the resolution is at an insufficient level
-
checkLevelIgnoreResolving
public void checkLevelIgnoreResolving(int level)
Checks if the class has at least the resolving level specified. This check ignores the resolution completeness.- Parameters:
level- the resolution level, one of DANGLING, HIERARCHY, SIGNATURES, and BODIES- Throws:
RuntimeException- if the resolution is at an insufficient level
-
resolvingLevel
public int resolvingLevel()
-
setResolvingLevel
public void setResolvingLevel(int newLevel)
-
isInScene
public boolean isInScene()
-
setInScene
public void setInScene(boolean isInScene)
Tells this class if it is being managed by a Scene.
-
getFieldCount
public int getFieldCount()
Returns the number of fields in this class.
-
addField
public void addField(SootField f)
Adds the given field to this class.
-
removeField
public void removeField(SootField f)
Removes the given field from this class.
-
getField
public SootField getField(String name, Type type)
Returns the field of this class with the given name and type. If the field cannot be found, an exception is thrown.
-
getFieldUnsafe
public SootField getFieldUnsafe(String name, Type type)
Returns the field of this class with the given name and type. If the field cannot be found, null is returned.
-
getFieldByName
public SootField getFieldByName(String name)
Returns the field of this class with the given name. Throws a RuntimeException if there is more than one field with the given name or if no such field exists at all.
-
getFieldByNameUnsafe
public SootField getFieldByNameUnsafe(String name)
Returns the field of this class with the given name. Throws a RuntimeException if there is more than one field with the given name. Returns null if no field with the given name exists.
-
getField
public SootField getField(String subsignature)
Returns the field of this class with the given subsignature. If such a field does not exist, an exception is thrown.
-
getFieldUnsafe
public SootField getFieldUnsafe(String subsignature)
Returns the field of this class with the given subsignature. If such a field does not exist, null is returned.
-
declaresField
public boolean declaresField(String subsignature)
Does this class declare a field with the given subsignature?
-
getMethod
public SootMethod getMethod(NumberedString subsignature)
Returns the method of this class with the given subsignature. If no method with the given subsignature can be found, an exception is thrown.
-
getMethodUnsafe
public SootMethod getMethodUnsafe(NumberedString subsignature)
Returns the method of this class with the given subsignature. If no method with the given subsignature can be found, null is returned.
-
declaresMethod
public boolean declaresMethod(NumberedString subsignature)
Does this class declare a method with the given subsignature?
-
getMethod
public SootMethod getMethod(String subsignature)
-
getMethodUnsafe
public SootMethod getMethodUnsafe(String subsignature)
-
declaresMethod
public boolean declaresMethod(String subsignature)
Does this class declare a method with the given subsignature?
-
declaresFieldByName
public boolean declaresFieldByName(String name)
Does this class declare a field with the given name?
-
declaresField
public boolean declaresField(String name, Type type)
Does this class declare a field with the given name and type.
-
getMethodCount
public int getMethodCount()
Returns the number of methods in this class.
-
methodIterator
public Iterator<SootMethod> methodIterator()
Returns an iterator over the methods in this class.
-
getMethods
public List<SootMethod> getMethods()
-
getMethod
public SootMethod getMethod(String name, List<Type> parameterTypes, Type returnType)
Attempts to retrieve the method with the given name, parameters and return type. If no matching method can be found, an exception is thrown.
-
getMethodUnsafe
public SootMethod getMethodUnsafe(String name, List<Type> parameterTypes, Type returnType)
Attempts to retrieve the method with the given name, parameters and return type. If no matching method can be found, null is returned.
-
getMethod
public SootMethod getMethod(String name, List<Type> parameterTypes)
Attempts to retrieve the method with the given name and parameters. This method may throw an AmbiguousMethodException if there is more than one method with the given name and parameter.
-
getMethodByNameUnsafe
public SootMethod getMethodByNameUnsafe(String name)
Attempts to retrieve the method with the given name. This method may throw an AmbiguousMethodException if there are more than one method with the given name. If no method with the given is found, null is returned.
-
getMethodByName
public SootMethod getMethodByName(String name)
Attempts to retrieve the method with the given name. This method may throw an AmbiguousMethodException if there are more than one method with the given name. If no method with the given is found, an exception is thrown as well.
-
declaresMethod
public boolean declaresMethod(String name, List<Type> parameterTypes)
Does this class declare a method with the given name and parameter types?
-
declaresMethod
public boolean declaresMethod(String name, List<Type> parameterTypes, Type returnType)
Does this class declare a method with the given name, parameter types, and return type?
-
declaresMethodByName
public boolean declaresMethodByName(String name)
Does this class declare a method with the given name?
-
addMethod
public void addMethod(SootMethod m)
Adds the given method to this class.
-
getOrAddMethod
public SootMethod getOrAddMethod(SootMethod m)
-
removeMethod
public void removeMethod(SootMethod m)
Removes the given method from this class.
-
getModifiers
public int getModifiers()
Returns the modifiers of this class.
-
setModifiers
public void setModifiers(int modifiers)
Sets the modifiers for this class.
-
getInterfaceCount
public int getInterfaceCount()
Returns the number of interfaces being directly implemented by this class. Note that direct implementation corresponds to an "implements" keyword in the Java class file and that this class may still be implementing additional interfaces in the usual sense by being a subclass of a class which directly implements some interfaces.
-
getInterfaces
public Chain<SootClass> getInterfaces()
Returns a backed Chain of the interfaces that are directly implemented by this class. (see getInterfaceCount())
-
implementsInterface
public boolean implementsInterface(String name)
Does this class directly implement the given interface? (see getInterfaceCount())
-
addInterface
public void addInterface(SootClass interfaceClass)
Add the given class to the list of interfaces which are directly implemented by this class.
-
removeInterface
public void removeInterface(SootClass interfaceClass)
Removes the given class from the list of interfaces which are directly implemented by this class.
-
hasSuperclass
public boolean hasSuperclass()
WARNING: interfaces are subclasses of the java.lang.Object class! Does this class have a superclass? False implies that this is the java.lang.Object class. Note that interfaces are subclasses of the java.lang.Object class.
-
getSuperclass
public SootClass getSuperclass()
WARNING: interfaces are subclasses of the java.lang.Object class! Returns the superclass of this class. (see hasSuperclass())
-
getSuperclassUnsafe
public SootClass getSuperclassUnsafe()
This method returns the superclass, or null if no superclass has been specified for this class. WARNING: interfaces are subclasses of the java.lang.Object class! Returns the superclass of this class. (see hasSuperclass())
-
setSuperclass
public void setSuperclass(SootClass c)
Sets the superclass of this class. Note that passing a null will cause the class to have no superclass.
-
hasOuterClass
public boolean hasOuterClass()
-
getOuterClass
public SootClass getOuterClass()
-
getOuterClassUnsafe
public SootClass getOuterClassUnsafe()
This method returns the outer class, or null if no outer class has been specified for this class.
-
setOuterClass
public void setOuterClass(SootClass c)
-
isInnerClass
public boolean isInnerClass()
-
getName
public String getName()
Returns the name of this class.
-
getJavaStyleName
public String getJavaStyleName()
-
getShortJavaStyleName
public String getShortJavaStyleName()
-
getShortName
public String getShortName()
-
getPackageName
public String getPackageName()
Returns the package name of this class.
-
getJavaPackageName
public String getJavaPackageName()
-
setName
public void setName(String name)
Sets the name of this class.
-
isInterface
public boolean isInterface()
Convenience method; returns true if this class is an interface.
-
isEnum
public boolean isEnum()
Convenience method; returns true if this class is an enumeration.
-
isSynchronized
public boolean isSynchronized()
Convenience method; returns true if this class is synchronized.
-
isConcrete
public boolean isConcrete()
Returns true if this class is not an interface and not abstract.
-
isPublic
public boolean isPublic()
Convenience method; returns true if this class is public.
-
containsBafBody
public boolean containsBafBody()
Returns true if some method in this class has an active Baf body.
-
setRefType
public void setRefType(RefType refType)
-
hasRefType
public boolean hasRefType()
-
getType
public RefType getType()
Returns the RefType corresponding to this class.
-
toString
public String toString()
Returns the name of this class.
-
renameFieldsAndMethods
public void renameFieldsAndMethods(boolean privateOnly)
Renames private fields and methods with numeric names.
-
isApplicationClass
public boolean isApplicationClass()
Convenience method returning true if this class is an application class.- See Also:
Scene.getApplicationClasses()
-
setApplicationClass
public void setApplicationClass()
Makes this class an application class.
-
isLibraryClass
public boolean isLibraryClass()
Convenience method returning true if this class is a library class.- See Also:
Scene.getLibraryClasses()
-
setLibraryClass
public void setLibraryClass()
Makes this class a library class.
-
isJavaLibraryClass
public boolean isJavaLibraryClass()
Sometimes we need to know which class is a JDK class. There is no simple way to distinguish a user class and a JDK class, here we use the package prefix as the heuristic.
-
isPhantomClass
public boolean isPhantomClass()
Convenience method returning true if this class is a phantom class.- See Also:
Scene.getPhantomClasses()
-
setPhantomClass
public void setPhantomClass()
Makes this class a phantom class.
-
isPhantom
public boolean isPhantom()
Convenience method returning true if this class is phantom.
-
isPrivate
public boolean isPrivate()
Convenience method returning true if this class is private.
-
isProtected
public boolean isProtected()
Convenience method returning true if this class is protected.
-
isAbstract
public boolean isAbstract()
Convenience method returning true if this class is abstract.
-
isFinal
public boolean isFinal()
Convenience method returning true if this class is final.
-
isStatic
public boolean isStatic()
Convenience method returning true if this class is static.
-
rename
public void rename(String newName)
-
validate
public void validate()
Validates this SootClass for logical errors. Note that this does not validate the method bodies, only the class structure.
-
validate
public void validate(List<ValidationException> exceptionList)
Validates this SootClass for logical errors. Note that this does not validate the method bodies, only the class structure. All found errors are saved into the given list.
-
getFilePath
public String getFilePath()
-
getModuleInformation
public SootModuleInfo getModuleInformation()
-
setModuleInformation
public void setModuleInformation(SootModuleInfo moduleInformation)
-
isExportedByModule
public boolean isExportedByModule()
Checks if this class is exported by it's module- Returns:
- true if the class is public exported
-
isExportedByModule
public boolean isExportedByModule(String toModule)
Checks if this class is exported by it's module- Returns:
- true if the class is public exported
-
isOpenedByModule
public boolean isOpenedByModule()
-
getMethodsByNameAndParamCount
public Collection<SootMethod> getMethodsByNameAndParamCount(String name, int paramCount)
Returns all methods with exactly the number of parameters specified.- Parameters:
name- the name of the methodparamCount- the parameter count- Returns:
- the methods
-
-