Package sootup.java.core
Class JavaSootMethod
- All Implemented Interfaces:
HasPosition,Method,SootMethod,HasAnnotation
public class JavaSootMethod
extends SootClassMember<MethodSignature>
implements SootMethod, HasAnnotation
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classDefines aJavaSootMethod.JavaSootMethodBuilderto provide a fluent API. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final @NonNull BodySourceTells 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 TypeMethodDescriptionbooleanintReturns a hash code for this method consistent with structural equality.@NonNull Iterable<AnnotationUsage>@NonNull BodygetBody()Retrieves the active body for this method.@NonNull BodySource@NonNull ClassTypeReturns the SootClass declaring this one.@NonNull ClassType@NonNull Set<MethodModifier>Gets the modifiers of this class member in an immutable set.@NonNull StringgetName()intReturns the number of parameters taken by this method.@NonNull TypegetParameterType(int n) @NonNull Type@NonNull MethodSubSignaturebooleanhasBody()Returns true if this method has a body.inthashCode()booleanConvenience method returning true if this method is abstract.booleanReturns true if this method is not abstract or native, i.e. this method can have a body.booleanisConstructor(@NonNull IdentifierFactory idf) booleanisDefaultConstructor(@NonNull IdentifierFactory idf) booleanisFinal()Convenience method returning true if this field is final.booleanisMain(@NonNull IdentifierFactory idf) booleanisNative()Convenience method returning true if this method is native.booleanConvenience method returning true if this class member is private.booleanConvenience method returning true if this class member is protected.booleanisPublic()Convenience method returning true if this class member is public.booleanisStatic()Convenience method returning true if this class member is static.booleanConvenience method returning true if this method is synchronized.voidtoString(@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 JavaSootMethodwithAnnotations(@NonNull Iterable<AnnotationUsage> annotations) @NonNull JavaSootMethod@NonNull JavaSootMethodwithModifiers(@NonNull Iterable<MethodModifier> modifiers) @NonNull JavaSootMethodwithOverridingMethodSource(@NonNull Function<OverridingBodySource, OverridingBodySource> overrider) Creates a new SootMethod based on a newOverridingBodySource.@NonNull JavaSootMethodwithSource(@NonNull BodySource source) @NonNull JavaSootMethodwithThrownExceptions(@NonNull Iterable<ClassType> thrownExceptions) Methods inherited from class sootup.core.model.SootClassMember
getPosition, getSignature, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods 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:SootClassMemberConvenience method returning true if this class member is protected.- Specified by:
isProtectedin interfaceSootMethod- Specified by:
isProtectedin classSootClassMember<MethodSignature>
-
isPrivate
public boolean isPrivate()Description copied from class:SootClassMemberConvenience method returning true if this class member is private.- Specified by:
isPrivatein interfaceSootMethod- Specified by:
isPrivatein classSootClassMember<MethodSignature>
-
isPublic
public boolean isPublic()Description copied from class:SootClassMemberConvenience method returning true if this class member is public.- Specified by:
isPublicin interfaceSootMethod- Specified by:
isPublicin classSootClassMember<MethodSignature>
-
isStatic
public boolean isStatic()Description copied from class:SootClassMemberConvenience method returning true if this class member is static.- Specified by:
isStaticin interfaceSootMethod- Specified by:
isStaticin classSootClassMember<MethodSignature>
-
isFinal
public boolean isFinal()Description copied from class:SootClassMemberConvenience method returning true if this field is final.- Specified by:
isFinalin interfaceSootMethod- Specified by:
isFinalin classSootClassMember<MethodSignature>
-
getModifiers
Gets the modifiers of this class member in an immutable set.- Specified by:
getModifiersin interfaceSootMethod- See Also:
-
equivHashCode
public int equivHashCode()Description copied from class:SootClassMemberReturns a hash code for this method consistent with structural equality.- Specified by:
equivHashCodein 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:
isConcretein interfaceSootMethod
-
getReturnType
- Specified by:
getReturnTypein interfaceSootMethod
-
getParameterCount
public int getParameterCount()Returns the number of parameters taken by this method.- Specified by:
getParameterCountin interfaceSootMethod
-
getParameterType
- Specified by:
getParameterTypein interfaceSootMethod
-
getSubSignature
- Specified by:
getSubSignaturein interfaceSootMethod
-
getParameterTypes
- Specified by:
getParameterTypesin interfaceSootMethod
-
getDeclClassType
- Specified by:
getDeclClassTypein interfaceSootMethod
-
getDeclaringClassType
Returns the SootClass declaring this one.- Specified by:
getDeclaringClassTypein interfaceSootMethod- Overrides:
getDeclaringClassTypein classSootClassMember<MethodSignature>
-
getName
- Specified by:
getNamein interfaceSootMethod- Overrides:
getNamein classSootClassMember<MethodSignature>
-
getBody
Retrieves the active body for this method.- Specified by:
getBodyin interfaceSootMethod
-
hasBody
public boolean hasBody()Returns true if this method has a body.- Specified by:
hasBodyin interfaceSootMethod
-
getBodySource
- Specified by:
getBodySourcein interfaceSootMethod
-
getExceptionSignatures
- Specified by:
getExceptionSignaturesin interfaceSootMethod
-
isAbstract
public boolean isAbstract()Convenience method returning true if this method is abstract.- Specified by:
isAbstractin interfaceSootMethod
-
isNative
public boolean isNative()Convenience method returning true if this method is native.- Specified by:
isNativein interfaceSootMethod
-
isSynchronized
public boolean isSynchronized()Convenience method returning true if this method is synchronized.- Specified by:
isSynchronizedin interfaceSootMethod
-
isMain
- Specified by:
isMainin interfaceSootMethod- Returns:
- yes if this is the main method
-
isConstructor
- Specified by:
isConstructorin interfaceSootMethod- Returns:
- true if the method is a constructor
-
isDefaultConstructor
- Specified by:
isDefaultConstructorin interfaceSootMethod- Returns:
- true if the method is the default constructor
-
getDefaultValue
- Returns:
- returns default value of annotation. May be null, if there is no default value
-
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:
toStringin interfaceSootMethod
-
hashCode
public int hashCode() -
equals
-
getAnnotations
- Specified by:
getAnnotationsin 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 aSootMethodwithout recreating aBodySourcecompletely.OverridingBodySourceallows for replacing the body of a method.- Specified by:
withOverridingMethodSourcein interfaceSootMethod
-
withSource
- Specified by:
withSourcein interfaceSootMethod
-
withModifiers
- Specified by:
withModifiersin interfaceSootMethod
-
withThrownExceptions
- Specified by:
withThrownExceptionsin interfaceSootMethod
-
withAnnotations
-
withBody
- Specified by:
withBodyin interfaceSootMethod
-