soot
Class SootClass

java.lang.Object
  extended by soot.tagkit.AbstractHost
      extended by soot.SootClass
All Implemented Interfaces:
Host, Numberable

public class SootClass
extends AbstractHost
implements Numberable

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
static int BODIES
           
static int DANGLING
           
protected  Chain<SootField> fields
           
protected  String fixedPackageName
           
protected  String fixedShortName
           
static int HIERARCHY
           
protected  Chain<SootClass> interfaces
           
static String INVOKEDYNAMIC_DUMMY_CLASS_NAME
           
protected  boolean isInScene
           
protected  boolean isPhantom
           
protected  List<SootMethod> methodList
           
protected  int modifiers
           
protected  String name
           
protected  SootClass outerClass
           
protected  String packageName
           
protected  String shortName
           
static int SIGNATURES
           
protected  SmallNumberedMap subSigToMethods
           
protected  SootClass superClass
           
 
Constructor Summary
SootClass(String name)
          Constructs an empty SootClass with the given name and no modifiers.
SootClass(String name, int modifiers)
          Constructs an empty SootClass with the given name and modifiers.
 
Method Summary
 void addField(SootField f)
          Adds the given field to this class.
 void addInterface(SootClass interfaceClass)
          Add the given class to the list of interfaces which are directly implemented by this class.
 void addMethod(SootMethod m)
          Adds the given method to this class.
 void checkLevel(int level)
           
 boolean containsBafBody()
          Returns true if some method in this class has an active Baf body.
 boolean declaresField(String subsignature)
          Does this class declare a field with the given subsignature?
 boolean declaresField(String name, Type type)
          Does this class declare a field with the given name and type.
 boolean declaresFieldByName(String name)
          Does this class declare a field with the given name?
 boolean declaresMethod(NumberedString subsignature)
          Does this class declare a method with the given subsignature?
 boolean declaresMethod(String subsignature)
          Does this class declare a method with the given subsignature?
 boolean declaresMethod(String name, List parameterTypes)
          Does this class declare a method with the given name and parameter types?
 boolean declaresMethod(String name, List parameterTypes, Type returnType)
          Does this class declare a method with the given name, parameter types, and return type?
 boolean declaresMethodByName(String name)
          Does this class declare a method with the given name?
 SootField getField(String subsignature)
           
 SootField getField(String name, Type type)
          Returns the field of this class with the given name and type.
 SootField getFieldByName(String name)
          Returns the field of this class with the given name.
 int getFieldCount()
          Returns the number of fields in this class.
 Chain<SootField> getFields()
          Returns a backed Chain of fields.
 int getInterfaceCount()
          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.
 String getJavaPackageName()
           
 String getJavaStyleName()
           
 SootMethod getMethod(NumberedString subsignature)
           
 SootMethod getMethod(String subsignature)
           
 SootMethod getMethod(String name, List parameterTypes)
          Attempts to retrieve the method with the given name and parameters.
 SootMethod getMethod(String name, List parameterTypes, Type returnType)
           
 SootMethod getMethodByName(String name)
          Attempts to retrieve the method with the given name.
 int getMethodCount()
          Returns the number of methods in this class.
 List<SootMethod> getMethods()
           
 int getModifiers()
          Returns the modifiers of this class.
 String getName()
          Returns the name of this class.
 int getNumber()
           
 SootClass getOuterClass()
           
 String getPackageName()
          Returns the package name of this class.
 String getShortJavaStyleName()
           
 String getShortName()
           
 SootClass getSuperclass()
          WARNING: interfaces are subclasses of the java.lang.Object class! Returns the superclass of this class.
 RefType getType()
          Returns the RefType corresponding to this class.
 boolean hasOuterClass()
           
 boolean hasRefType()
           
 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.
 boolean implementsInterface(String name)
          Does this class directly implement the given interface? (see getInterfaceCount())
 boolean isAbstract()
          Convenience method returning true if this class is abstract.
 boolean isApplicationClass()
          Convenience method returning true if this class is an application class.
 boolean isConcrete()
          Returns true if this class is not an interface and not abstract.
 boolean isInScene()
           
 boolean isInterface()
          Convenience method; returns true if this class is an interface.
 boolean isJavaLibraryClass()
          Sometimes we need to know which class is a JDK class.
 boolean isLibraryClass()
          Convenience method returning true if this class is a library class.
 boolean isPhantom()
          Convenience method returning true if this class is phantom.
 boolean isPhantomClass()
          Convenience method returning true if this class is a phantom class.
 boolean isPrivate()
          Convenience method returning true if this class is private.
 boolean isProtected()
          Convenience method returning true if this class is protected.
 boolean isPublic()
          Convenience method; returns true if this class is public.
 Iterator<SootMethod> methodIterator()
          Returns an iterator over the methods in this class.
 void removeField(SootField f)
          Removes the given field from this class.
 void removeInterface(SootClass interfaceClass)
          Removes the given class from the list of interfaces which are direclty implemented by this class.
 void removeMethod(SootMethod m)
          Removes the given method from this class.
 void renameFieldsAndMethods(boolean privateOnly)
           
 int resolvingLevel()
           
 void setApplicationClass()
          Makes this class an application class.
 void setInScene(boolean isInScene)
          Tells this class if it is being managed by a Scene.
 void setLibraryClass()
          Makes this class a library class.
 void setModifiers(int modifiers)
          Sets the modifiers for this class.
 void setName(String name)
          Sets the name of this class.
 void setNumber(int number)
           
 void setOuterClass(SootClass c)
           
 void setPhantom(boolean value)
          Marks this class as phantom, without notifying the Scene.
 void setPhantomClass()
          Makes this class a phantom class.
 void setRefType(RefType refType)
           
 void setResolvingLevel(int newLevel)
           
 void setSuperclass(SootClass c)
          Sets the superclass of this class.
 String toString()
          Returns the name of this class.
 
Methods inherited from class soot.tagkit.AbstractHost
addAllTagsOf, addTag, getTag, getTags, hasTag, removeAllTags, removeTag
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

name

protected String name

shortName

protected String shortName

fixedShortName

protected String fixedShortName

packageName

protected String packageName

fixedPackageName

protected String fixedPackageName

modifiers

protected int modifiers

fields

protected Chain<SootField> fields

subSigToMethods

protected SmallNumberedMap subSigToMethods

methodList

protected List<SootMethod> methodList

interfaces

protected Chain<SootClass> interfaces

isInScene

protected boolean isInScene

superClass

protected SootClass superClass

outerClass

protected SootClass outerClass

isPhantom

protected boolean isPhantom

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
Constructor Detail

SootClass

public SootClass(String name,
                 int modifiers)
Constructs an empty SootClass with the given name and modifiers.


SootClass

public SootClass(String name)
Constructs an empty SootClass with the given name and no modifiers.

Method Detail

checkLevel

public void checkLevel(int 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.


getFields

public Chain<SootField> getFields()
Returns a backed Chain of fields.


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.


getFieldByName

public SootField getFieldByName(String name)
Returns the field of this class with the given name. Throws a RuntimeException if there are more than one.


getField

public SootField getField(String subsignature)

declaresField

public boolean declaresField(String subsignature)
Does this class declare a field with the given subsignature?


getMethod

public SootMethod getMethod(NumberedString subsignature)

declaresMethod

public boolean declaresMethod(NumberedString subsignature)
Does this class declare a method with the given subsignature?


getMethod

public SootMethod getMethod(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 parameterTypes,
                            Type returnType)

getMethod

public SootMethod getMethod(String name,
                            List 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.


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.


declaresMethod

public boolean declaresMethod(String name,
                              List parameterTypes)
Does this class declare a method with the given name and parameter types?


declaresMethod

public boolean declaresMethod(String name,
                              List 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.


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 direclty 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())


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()

setOuterClass

public void setOuterClass(SootClass c)

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.


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.

Overrides:
toString in class Object

renameFieldsAndMethods

public void renameFieldsAndMethods(boolean privateOnly)

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.


setPhantom

public void setPhantom(boolean value)
Marks this class as phantom, without notifying the Scene.


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.


getNumber

public final int getNumber()
Specified by:
getNumber in interface Numberable

setNumber

public final void setNumber(int number)
Specified by:
setNumber in interface Numberable