soot
Class SootMethod

java.lang.Object
  |
  +--soot.tagkit.AbstractHost
        |
        +--soot.SootMethod

public class SootMethod
extends AbstractHost
implements ClassMember, Numberable

Soot representation of a Java method. Can be declared to belong to a SootClass. Does not contain the actual code, which belongs to a Body. The getActiveBody() method points to the currently-active body.


Field Summary
static java.lang.String constructorName
           
protected  MethodSource ms
          Tells this method how to find out where its body lives.
static java.lang.String staticInitializerName
           
 
Constructor Summary
SootMethod(java.lang.String name, java.util.List parameterTypes, Type returnType)
          Constructs a SootMethod with the given name, parameter types and return type.
SootMethod(java.lang.String name, java.util.List parameterTypes, Type returnType, int modifiers)
          Constructs a SootMethod with the given name, parameter types, return type and modifiers.
SootMethod(java.lang.String name, java.util.List parameterTypes, Type returnType, int modifiers, java.util.List thrownExceptions)
          Constructs a SootMethod with the given name, parameter types, return type, and list of thrown exceptions.
 
Method Summary
 void addException(SootClass e)
          Adds the given exception to the list of exceptions thrown by this method.
 int equivHashCode()
          Returns a hash code for this method consistent with structural equality.
 Body getActiveBody()
          Retrieves the active body for this method.
 java.lang.String getBytecodeSignature()
          Returns the signature of this method in the format in which it appears in bytecode (eg.
 java.lang.String getDavaDeclaration()
           
 java.lang.String getDeclaration()
          Returns the declaration of this method, as used at the top of textual body representations (before the {}'s containing the code for representation.)
 SootClass getDeclaringClass()
          Returns the class which declares the current SootMethod.
 java.util.List getExceptions()
          Returns a backed list of the exceptions thrown by this method.
 int getModifiers()
          Gets the modifiers of this method.
 java.lang.String getName()
          Returns the name of this method.
 int getNumber()
           
 NumberedString getNumberedSubSignature()
           
 int getParameterCount()
          Returns the number of parameters taken by this method.
 Type getParameterType(int n)
          Gets the type of the nth parameter of this method.
 java.util.List getParameterTypes()
          Returns a backed list of the parameter types of this method.
 Type getReturnType()
          Returns the return type of this method.
 java.lang.String getSignature()
          Returns the Soot signature of this method.
 MethodSource getSource()
          Returns the MethodSource of the current SootMethod.
 java.lang.String getSubSignature()
          Returns the Soot subsignature of this method.
static java.lang.String getSubSignature(java.lang.String name, java.util.List params, Type returnType)
           
 boolean hasActiveBody()
          Returns true if this method has an active body.
 boolean isAbstract()
          Convenience method returning true if this method is abstract.
 boolean isConcrete()
          Returns true if this method is not phantom, abstract or native, i.e.
 boolean isDeclared()
          Returns true when some SootClass object declares this SootMethod object.
 boolean isNative()
          Convenience method returning true if this method is native.
 boolean isPhantom()
          Returns true when this SootMethod object is phantom.
 boolean isPrivate()
          Convenience method returning true if this method is private.
 boolean isProtected()
          Convenience method returning true if this method is protected.
 boolean isPublic()
          Convenience method returning true if this method is public.
 boolean isStatic()
          Convenience method returning true if this method is static.
 boolean isSynchronized()
          Convenience method returning true if this method is synchronized.
 void releaseActiveBody()
          Releases the active body associated with this method.
 void removeException(SootClass e)
          Removes the given exception from the list of exceptions thrown by this method.
 Body retrieveActiveBody()
          Returns the active body if present, else constructs an active body and returns that.
 void setActiveBody(Body body)
          Sets the active body for this method.
 void setDeclared(boolean isDeclared)
           
 void setExceptions(java.util.List exceptions)
           
 void setModifiers(int modifiers)
          Sets the modifiers of this method.
 void setName(java.lang.String name)
          Sets the name of this method.
 void setNumber(int number)
           
 void setParameterTypes(java.util.List parameterTypes)
          Sets the list of parameter types for this method as given.
 void setPhantom(boolean value)
          Sets the phantom flag on this method.
 void setReturnType(Type t)
          Sets the return type of this method.
 void setSource(MethodSource ms)
          Sets the MethodSource of the current SootMethod.
 boolean throwsException(SootClass e)
          Returns true if this method throws exception e.
 java.lang.String toString()
          Returns the signature of this method.
 
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

constructorName

public static final java.lang.String constructorName

staticInitializerName

public static final java.lang.String staticInitializerName

ms

protected MethodSource ms
Tells this method how to find out where its body lives.
Constructor Detail

SootMethod

public SootMethod(java.lang.String name,
                  java.util.List parameterTypes,
                  Type returnType)
Constructs a SootMethod with the given name, parameter types and return type.

SootMethod

public SootMethod(java.lang.String name,
                  java.util.List parameterTypes,
                  Type returnType,
                  int modifiers)
Constructs a SootMethod with the given name, parameter types, return type and modifiers.

SootMethod

public SootMethod(java.lang.String name,
                  java.util.List parameterTypes,
                  Type returnType,
                  int modifiers,
                  java.util.List thrownExceptions)
Constructs a SootMethod with the given name, parameter types, return type, and list of thrown exceptions.
Method Detail

setSource

public void setSource(MethodSource ms)
Sets the MethodSource of the current SootMethod.

getSource

public MethodSource getSource()
Returns the MethodSource of the current SootMethod.

equivHashCode

public int equivHashCode()
Returns a hash code for this method consistent with structural equality.

getName

public java.lang.String getName()
Returns the name of this method.

getDeclaringClass

public SootClass getDeclaringClass()
Returns the class which declares the current SootMethod.
Specified by:
getDeclaringClass in interface ClassMember

setDeclared

public void setDeclared(boolean isDeclared)

isDeclared

public boolean isDeclared()
Returns true when some SootClass object declares this SootMethod object.
Specified by:
isDeclared in interface ClassMember

isPhantom

public boolean isPhantom()
Returns true when this SootMethod object is phantom.
Specified by:
isPhantom in interface ClassMember

isConcrete

public boolean isConcrete()
Returns true if this method is not phantom, abstract or native, i.e. this method can have a body.

setPhantom

public void setPhantom(boolean value)
Sets the phantom flag on this method.

setName

public void setName(java.lang.String name)
Sets the name of this method.

getModifiers

public int getModifiers()
Gets the modifiers of this method.
Specified by:
getModifiers in interface ClassMember
See Also:
Modifier

setModifiers

public void setModifiers(int modifiers)
Sets the modifiers of this method.
Specified by:
setModifiers in interface ClassMember
See Also:
Modifier

getReturnType

public Type getReturnType()
Returns the return type of this method.

setReturnType

public void setReturnType(Type t)
Sets the return type of this method.

getParameterCount

public int getParameterCount()
Returns the number of parameters taken by this method.

getParameterType

public Type getParameterType(int n)
Gets the type of the nth parameter of this method.

getParameterTypes

public java.util.List getParameterTypes()
Returns a backed list of the parameter types of this method.

getActiveBody

public Body getActiveBody()
Retrieves the active body for this method.

retrieveActiveBody

public Body retrieveActiveBody()
Returns the active body if present, else constructs an active body and returns that. If you called Scene.v().loadClassAndSupport() for a class yourself, it will not be an application class, so you cannot get retrieve its active body. Please call setApplicationClass() on the relevant class.

setActiveBody

public void setActiveBody(Body body)
Sets the active body for this method.

hasActiveBody

public boolean hasActiveBody()
Returns true if this method has an active body.

releaseActiveBody

public void releaseActiveBody()
Releases the active body associated with this method.

addException

public void addException(SootClass e)
Adds the given exception to the list of exceptions thrown by this method.

removeException

public void removeException(SootClass e)
Removes the given exception from the list of exceptions thrown by this method.

throwsException

public boolean throwsException(SootClass e)
Returns true if this method throws exception e.

setExceptions

public void setExceptions(java.util.List exceptions)

getExceptions

public java.util.List getExceptions()
Returns a backed list of the exceptions thrown by this method.

setParameterTypes

public void setParameterTypes(java.util.List parameterTypes)
Sets the list of parameter types for this method as given. This method makes a copy of the given list.

isStatic

public boolean isStatic()
Convenience method returning true if this method is static.
Specified by:
isStatic in interface ClassMember

isPrivate

public boolean isPrivate()
Convenience method returning true if this method is private.
Specified by:
isPrivate in interface ClassMember

isPublic

public boolean isPublic()
Convenience method returning true if this method is public.
Specified by:
isPublic in interface ClassMember

isProtected

public boolean isProtected()
Convenience method returning true if this method is protected.
Specified by:
isProtected in interface ClassMember

isAbstract

public boolean isAbstract()
Convenience method returning true if this method is abstract.

isNative

public boolean isNative()
Convenience method returning true if this method is native.

isSynchronized

public boolean isSynchronized()
Convenience method returning true if this method is synchronized.

getBytecodeSignature

public java.lang.String getBytecodeSignature()
Returns the signature of this method in the format in which it appears in bytecode (eg. [Ljava/lang/Object instead of java.lang.Object[]).

getSignature

public java.lang.String getSignature()
Returns the Soot signature of this method. Used to refer to methods unambiguously.

getSubSignature

public java.lang.String getSubSignature()
Returns the Soot subsignature of this method. Used to refer to methods unambiguously.

getSubSignature

public static java.lang.String getSubSignature(java.lang.String name,
                                               java.util.List params,
                                               Type returnType)

getNumberedSubSignature

public NumberedString getNumberedSubSignature()

toString

public java.lang.String toString()
Returns the signature of this method.
Overrides:
toString in class java.lang.Object

getDavaDeclaration

public java.lang.String getDavaDeclaration()

getDeclaration

public java.lang.String getDeclaration()
Returns the declaration of this method, as used at the top of textual body representations (before the {}'s containing the code for representation.)

getNumber

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

setNumber

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