Package sootup.core.model
Class SootMethod
- All Implemented Interfaces:
HasPosition
,Method
- Direct Known Subclasses:
JavaSootMethod
Soot's counterpart of the source language's method concept. 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.
- Author:
- Linghui Luo, Jan Martin Persch
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
static interface
static interface
static interface
static class
Defines aSootMethod
builder that provides a fluent API.static interface
-
Field Summary
Modifier and TypeFieldDescriptionprotected final BodySource
Tells this method how to find out where its body lives.protected final com.google.common.collect.ImmutableList<ClassType>
Declared exceptions thrown by this method.protected final com.google.common.collect.ImmutableList<Type>
An array of parameter types taken by thisSootMethod
object, in declaration order. -
Constructor Summary
ConstructorDescriptionSootMethod
(BodySource source, MethodSignature methodSignature, Iterable<MethodModifier> modifiers, Iterable<ClassType> thrownExceptions, Position position) Constructs a SootMethod object with the given attributes. -
Method Summary
Modifier and TypeMethodDescriptionstatic SootMethod.MethodSourceStep
builder()
Creates a builder forSootMethod
s.boolean
int
Returns a hash code for this method consistent with structural equality.getBody()
Retrieves the active body for this method.Gets the modifiers of this class member in an immutable set.int
Returns the number of parameters taken by this method.getParameterType
(int n) Gets the type of the nth parameter of this method.Returns a read-only list of the parameter types of this method.boolean
hasBody()
Returns true if this method has a body.int
hashCode()
boolean
Convenience method returning true if this method is abstract.boolean
Returns true if this method is not abstract or native, i.e.boolean
isFinal()
Convenience method returning true if this field is final.boolean
isMain
(IdentifierFactory idf) boolean
isNative()
Convenience method returning true if this method is native.boolean
Convenience method returning true if this class member is private.boolean
Convenience method returning true if this class member is protected.boolean
isPublic()
Convenience method returning true if this class member is public.boolean
isStatic()
Convenience method returning true if this class member is static.boolean
Convenience method returning true if this method is synchronized.void
toString
(StmtPrinter printer) Returns the declaration of this method, as used at the top of textual body representations (before the {}'s containing the code for representation.)withModifiers
(Iterable<MethodModifier> modifiers) Creates a new SootMethod based on a newOverridingBodySource
.withSource
(BodySource source) withThrownExceptions
(Iterable<ClassType> thrownExceptions) Methods inherited from class sootup.core.model.SootClassMember
getDeclaringClassType, getName, getPosition, getSignature, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface sootup.core.model.Method
getSignature
-
Field Details
-
parameterTypes
An array of parameter types taken by thisSootMethod
object, in declaration order. -
exceptions
Declared exceptions thrown by this method. Created upon demand. -
bodySource
Tells this method how to find out where its body lives.
-
-
Constructor Details
-
SootMethod
public SootMethod(@Nonnull BodySource source, @Nonnull MethodSignature methodSignature, @Nonnull Iterable<MethodModifier> modifiers, @Nonnull Iterable<ClassType> thrownExceptions, @Nonnull Position position) Constructs a SootMethod object with the given attributes.
-
-
Method Details
-
isProtected
public boolean isProtected()Description copied from class:SootClassMember
Convenience method returning true if this class member is protected.- Specified by:
isProtected
in classSootClassMember<MethodSignature>
-
isPrivate
public boolean isPrivate()Description copied from class:SootClassMember
Convenience method returning true if this class member is private.- Specified by:
isPrivate
in classSootClassMember<MethodSignature>
-
isPublic
public boolean isPublic()Description copied from class:SootClassMember
Convenience method returning true if this class member is public.- Specified by:
isPublic
in classSootClassMember<MethodSignature>
-
isStatic
public boolean isStatic()Description copied from class:SootClassMember
Convenience method returning true if this class member is static.- Specified by:
isStatic
in classSootClassMember<MethodSignature>
-
isFinal
public boolean isFinal()Description copied from class:SootClassMember
Convenience method returning true if this field is final.- Specified by:
isFinal
in classSootClassMember<MethodSignature>
-
getModifiers
Gets the modifiers of this class member in an immutable set.- See Also:
-
equivHashCode
public int equivHashCode()Description copied from class:SootClassMember
Returns a hash code for this method consistent with structural equality.- Specified by:
equivHashCode
in classSootClassMember<MethodSignature>
-
isConcrete
public boolean isConcrete()Returns true if this method is not abstract or native, i.e. this method can have a body. -
getReturnType
-
getParameterCount
public int getParameterCount()Returns the number of parameters taken by this method. -
getParameterType
Gets the type of the nth parameter of this method. -
getParameterTypes
Returns a read-only list of the parameter types of this method. -
getBody
Retrieves the active body for this method. -
hasBody
public boolean hasBody()Returns true if this method has a body. -
getBodySource
-
getExceptionSignatures
-
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. -
isMain
- Returns:
- yes if this is the main method
-
toString
Returns the declaration of this method, as used at the top of textual body representations (before the {}'s containing the code for representation.) -
withOverridingMethodSource
@Nonnull public SootMethod withOverridingMethodSource(Function<OverridingBodySource, OverridingBodySource> overrider) Creates a new SootMethod based on a newOverridingBodySource
. This is useful to change selected parts of aSootMethod
without recreating aBodySource
completely.OverridingBodySource
allows for replacing the body of a method. -
withSource
-
withModifiers
-
withThrownExceptions
-
withBody
-
builder
Creates a builder forSootMethod
s.- Returns:
- A
SootMethod.SootMethodBuilder
.
-
hashCode
public int hashCode() -
equals
-