Package sootup.java.core
Class JavaSootMethod
- All Implemented Interfaces:
HasPosition
,Method
,SootMethod
,HasAnnotation
- Direct Known Subclasses:
JavaAnnotationSootMethod
public class JavaSootMethod
extends SootClassMember<MethodSignature>
implements SootMethod, HasAnnotation
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Defines aJavaSootMethod.JavaSootMethodBuilder
to provide a fluent API. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final @NonNull BodySource
Tells this method how to find out where its body lives.protected final @NonNull com.google.common.collect.ImmutableList<ClassType>
Declared exceptions thrown by this method.Fields inherited from class sootup.core.model.SootClassMember
position, signature
-
Constructor Summary
ConstructorsConstructorDescriptionJavaSootMethod
(@NonNull BodySource source, @NonNull MethodSignature methodSignature, @NonNull Iterable<MethodModifier> modifiers, @NonNull Iterable<ClassType> thrownExceptions, @NonNull Iterable<AnnotationUsage> annotations, @NonNull Position position) JavaSootMethod
(@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 Summary
Modifier and TypeMethodDescriptionboolean
int
Returns a hash code for this method consistent with structural equality.@NonNull Iterable<AnnotationUsage>
@NonNull Body
getBody()
Retrieves the active body for this method.@NonNull BodySource
@NonNull ClassType
Returns the SootClass declaring this one.@NonNull ClassType
@NonNull Set<MethodModifier>
Gets the modifiers of this class member in an immutable set.@NonNull String
getName()
int
Returns the number of parameters taken by this method.@NonNull Type
getParameterType
(int n) @NonNull Type
@NonNull MethodSubSignature
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. this method can have a body.boolean
isConstructor
(@NonNull IdentifierFactory idf) boolean
isDefaultConstructor
(@NonNull IdentifierFactory idf) boolean
isFinal()
Convenience method returning true if this field is final.boolean
isMain
(@NonNull 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
(@NonNull 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.)@NonNull JavaSootMethod
withAnnotations
(@NonNull Iterable<AnnotationUsage> annotations) @NonNull JavaSootMethod
@NonNull JavaSootMethod
withModifiers
(@NonNull Iterable<MethodModifier> modifiers) @NonNull JavaSootMethod
withOverridingMethodSource
(@NonNull Function<OverridingBodySource, OverridingBodySource> overrider) Creates a new SootMethod based on a newOverridingBodySource
.@NonNull JavaSootMethod
withSource
(@NonNull BodySource source) @NonNull JavaSootMethod
withThrownExceptions
(@NonNull Iterable<ClassType> thrownExceptions) Methods inherited from class sootup.core.model.SootClassMember
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.SootMethod
getPosition, getSignature
-
Field Details
-
exceptions
Declared exceptions thrown by this method. Created upon demand. -
bodySource
Tells this method how to find out where its body lives.
-
-
Constructor Details
-
JavaSootMethod
public JavaSootMethod(@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. -
JavaSootMethod
public JavaSootMethod(@NonNull BodySource source, @NonNull MethodSignature methodSignature, @NonNull Iterable<MethodModifier> modifiers, @NonNull Iterable<ClassType> thrownExceptions, @NonNull Iterable<AnnotationUsage> annotations, @NonNull Position position)
-
-
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 interfaceSootMethod
- 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 interfaceSootMethod
- 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 interfaceSootMethod
- 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 interfaceSootMethod
- 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 interfaceSootMethod
- Specified by:
isFinal
in classSootClassMember<MethodSignature>
-
getModifiers
Gets the modifiers of this class member in an immutable set.- Specified by:
getModifiers
in interfaceSootMethod
- 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.- Specified by:
isConcrete
in interfaceSootMethod
-
getReturnType
- Specified by:
getReturnType
in interfaceSootMethod
-
getParameterCount
public int getParameterCount()Returns the number of parameters taken by this method.- Specified by:
getParameterCount
in interfaceSootMethod
-
getParameterType
- Specified by:
getParameterType
in interfaceSootMethod
-
getSubSignature
- Specified by:
getSubSignature
in interfaceSootMethod
-
getParameterTypes
- Specified by:
getParameterTypes
in interfaceSootMethod
-
getDeclClassType
- Specified by:
getDeclClassType
in interfaceSootMethod
-
getDeclaringClassType
Returns the SootClass declaring this one.- Specified by:
getDeclaringClassType
in interfaceSootMethod
- Overrides:
getDeclaringClassType
in classSootClassMember<MethodSignature>
-
getName
- Specified by:
getName
in interfaceSootMethod
- Overrides:
getName
in classSootClassMember<MethodSignature>
-
getBody
Retrieves the active body for this method.- Specified by:
getBody
in interfaceSootMethod
-
hasBody
public boolean hasBody()Returns true if this method has a body.- Specified by:
hasBody
in interfaceSootMethod
-
getBodySource
- Specified by:
getBodySource
in interfaceSootMethod
-
getExceptionSignatures
- Specified by:
getExceptionSignatures
in interfaceSootMethod
-
isAbstract
public boolean isAbstract()Convenience method returning true if this method is abstract.- Specified by:
isAbstract
in interfaceSootMethod
-
isNative
public boolean isNative()Convenience method returning true if this method is native.- Specified by:
isNative
in interfaceSootMethod
-
isSynchronized
public boolean isSynchronized()Convenience method returning true if this method is synchronized.- Specified by:
isSynchronized
in interfaceSootMethod
-
isMain
- Specified by:
isMain
in interfaceSootMethod
- Returns:
- yes if this is the main method
-
isConstructor
- Specified by:
isConstructor
in interfaceSootMethod
- Returns:
- true if the method is a constructor
-
isDefaultConstructor
- Specified by:
isDefaultConstructor
in interfaceSootMethod
- Returns:
- true if the method is the default constructor
-
toString
Returns the declaration of this method, as used at the top of textual body representations (before the {}'s containing the code for representation.)- Specified by:
toString
in interfaceSootMethod
-
hashCode
public int hashCode() -
equals
-
getAnnotations
- Specified by:
getAnnotations
in interfaceHasAnnotation
-
withOverridingMethodSource
public @NonNull JavaSootMethod withOverridingMethodSource(@NonNull 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.- Specified by:
withOverridingMethodSource
in interfaceSootMethod
-
withSource
- Specified by:
withSource
in interfaceSootMethod
-
withModifiers
- Specified by:
withModifiers
in interfaceSootMethod
-
withThrownExceptions
- Specified by:
withThrownExceptions
in interfaceSootMethod
-
withAnnotations
-
withBody
- Specified by:
withBody
in interfaceSootMethod
-