Package soot

Class SootMethod

    • Field Detail

      • name

        protected String name
        Name of the current method.
      • parameterTypes

        protected Type[] parameterTypes
        An array of parameter types taken by this SootMethod object, in declaration order.
      • returnType

        protected Type returnType
        The return type of this object.
      • isDeclared

        protected boolean isDeclared
        True when some SootClass object declares this SootMethod object.
      • declaringClass

        protected SootClass declaringClass
        Holds the class which declares this SootClass method.
      • modifiers

        protected int modifiers
        Modifiers associated with this SootMethod (e.g. private, protected, etc.)
      • isPhantom

        protected boolean isPhantom
        Is this method a phantom method?
      • exceptions

        protected List<SootClass> exceptions
        Declared exceptions thrown by this method. Created upon demand.
      • activeBody

        protected volatile Body activeBody
        Active body associated with this method.
      • ms

        protected volatile MethodSource ms
        Tells this method how to find out where its body lives.
      • sig

        protected volatile String sig
      • subSig

        protected volatile String subSig
    • Constructor Detail

      • SootMethod

        public SootMethod​(String name,
                          List<Type> parameterTypes,
                          Type returnType)
        Constructs a SootMethod with the given name, parameter types and return type.
      • SootMethod

        public SootMethod​(String name,
                          List<Type> parameterTypes,
                          Type returnType,
                          int modifiers)
        Constructs a SootMethod with the given name, parameter types, return type and modifiers.
      • SootMethod

        public SootMethod​(String name,
                          List<Type> parameterTypes,
                          Type returnType,
                          int modifiers,
                          List<SootClass> thrownExceptions)
        Constructs a SootMethod with the given name, parameter types, return type, and list of thrown exceptions.
    • Method Detail

      • equivHashCode

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

        public void setName​(String name)
        Sets the name of this method.
      • setDeclaringClass

        public void setDeclaringClass​(SootClass declClass)
        Sets the declaring class
      • setDeclared

        public void setDeclared​(boolean isDeclared)
      • 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.
        Specified by:
        setPhantom in interface ClassMember
      • setModifiers

        public void setModifiers​(int modifiers)
        Sets the modifiers of this method.
        Specified by:
        setModifiers in interface ClassMember
        See Also:
        Modifier
      • 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.
      • setParameterTypes

        public void setParameterTypes​(List<Type> l)
        Changes the set of parameter types of this method.
      • getActiveBody

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

        public void setActiveBody​(Body body)
        Sets 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 SootClass.setApplicationClass() on the relevant class.
      • retrieveActiveBody

        public Body retrieveActiveBody​(Consumer<Body> consumer)
        Returns the active body if present, else constructs an active body, calls the consumer and returns the body afterward. 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 SootClass.setApplicationClass() on the relevant class.
        Parameters:
        consumer - Consumer that takes in the body of the method. The consumer is only invoked if the current invocation constructs a new body and is guaranteed to terminate before the body is available to other threads.
        Returns:
        active body of the 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.
      • addExceptionIfAbsent

        public void addExceptionIfAbsent​(SootClass e)
        Adds the given exception to the list of exceptions thrown by this method unless the exception is already in the list.
      • 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​(List<SootClass> exceptions)
      • getExceptions

        public List<SootClass> getExceptions()
        Returns a backed list of the exceptions thrown by this method.
      • getExceptionsUnsafe

        public List<SootClass> getExceptionsUnsafe()
      • 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.
      • isFinal

        public boolean isFinal()
        Convenience method returning true if this method is final.
      • 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

        public boolean isMain()
        Returns:
        yes if this is the main method
      • isConstructor

        public boolean isConstructor()
        Returns:
        yes, if this function is a constructor. Please not that methods are not treated as constructors in this method.
      • isStaticInitializer

        public boolean isStaticInitializer()
        Returns:
        yes, if this function is a static initializer.
      • isEntryMethod

        public boolean isEntryMethod()
        Returns:
        yes, if this is a class initializer or main function.
      • isJavaLibraryMethod

        public boolean isJavaLibraryMethod()
        We rely on the JDK class recognition to decide if a method is JDK method.
      • getBytecodeParms

        public String getBytecodeParms()
        Returns the parameters part of the signature in the format in which it appears in bytecode.
      • getBytecodeSignature

        public 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 String getSignature()
        Returns the Soot signature of this method. Used to refer to methods unambiguously.
        Specified by:
        getSignature in interface SootMethodInterface
        Returns:
        The Soot signature of this method. Used to refer to methods unambiguously.
      • getSubSignature

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

        public NumberedString getNumberedSubSignature()
      • toString

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

        public String getDavaDeclaration()
      • getDeclaration

        public 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.)
      • isValidResolve

        public boolean isValidResolve​(SootMethodRef ref)