Interface IJavaMethod

All Superinterfaces:
IJavaDecompilableElement, IJavaElement

@Ser public interface IJavaMethod extends IJavaDecompilableElement
Java AST interface to represent a Java method.
  • Method Details

    • getLabelFactory

      IJavaLabelFactory getLabelFactory()
      Retrieve the label factory associated with this method.
      Returns:
      the label factory
    • getIdentifierManager

      IJavaIdentifierManager getIdentifierManager()
      Retrieve the identifier manager associated with this method.
      Returns:
      the identifier manager
    • getName

      String getName()
      Get the original method name. The returned name is a simple name, without parameter, return, or type information.
      Specified by:
      getName in interface IJavaDecompilableElement
      Returns:
      the method name
    • getSignature

      String getSignature()
      Get the original method signature.
      Specified by:
      getSignature in interface IJavaDecompilableElement
      Returns:
      the method signature
    • getParameter

      IJavaDefinition getParameter(int index)
      Retrieve a method parameter by index.
      Parameters:
      index - parameter index
      Returns:
      the parameter definition
    • getParameterCount

      int getParameterCount()
      Retrieve the total number of parameters, including hidden parameters.
      Returns:
      parameter count
    • setIndexOfFirstVisibleParameter

      void setIndexOfFirstVisibleParameter(int index)
      Set the index of the first visible parameter.
      Parameters:
      index - parameter index
    • getIndexOfFirstVisibleParameter

      int getIndexOfFirstVisibleParameter()
      Retrieve the index of the first visible parameter.
      Returns:
      first visible parameter index
    • getVisibleParameterCount

      int getVisibleParameterCount()
      Retrieve the number of visible parameters.
      Returns:
      visible parameter count
    • getVisibleParameters

      List<IJavaDefinition> getVisibleParameters()
      Retrieve the visible parameters.
      Returns:
      list of visible parameter definitions
    • getParameters

      List<IJavaDefinition> getParameters()
      Get the parameters of the method.

      Note: If the method is non-static, the first parameter in the list would be `this`.

      Returns:
      the list of parameters
    • markSecondParameterOuterClassReference

      void markSecondParameterOuterClassReference()
      Mark the second parameter as an outer-class reference.
    • isSecondParameterOuterClassReference

      boolean isSecondParameterOuterClassReference()
      Determine whether the second parameter is an outer-class reference.
      Returns:
      true if the second parameter is an outer-class reference
    • getReturnType

      IJavaType getReturnType()
      Get the return type of the method.
      Returns:
      the return type
    • getBody

      IJavaBlock getBody()
      Get the body of the method.
      Returns:
      the body, null if none
    • isEmpty

      boolean isEmpty()
      Determine whether the method body is empty.
      Returns:
      true if the method has no statements
    • isConstructor

      boolean isConstructor()
      Determine whether this method is an instance constructor.
      Returns:
      true if this method is a constructor
    • isClassConstructor

      boolean isClassConstructor()
      Determine whether this method is a class constructor.
      Returns:
      true if this method is a class constructor
    • isClassInitializer

      boolean isClassInitializer()
      Determine whether this method is a class initializer.
      Returns:
      true if this method is a class initializer
    • getAccessFlags

      int getAccessFlags()
      Retrieve the method access flags.
      Returns:
      access flags
    • isStatic

      boolean isStatic()
      Determine whether this method is a static method.
      Returns:
      true if the method is static, false otherwise (virtual method)
    • isSynthetic

      boolean isSynthetic()
      Determine whether this method is synthetic.
      Returns:
      true if the method is synthetic
    • isAbstract

      boolean isAbstract()
      Determine whether this method is abstract.
      Returns:
      true if the method is abstract
    • isNative

      boolean isNative()
      Determine whether this method is native.
      Returns:
      true if the method is native
    • isPublic

      boolean isPublic()
      Determine whether this method is public.
      Returns:
      true if the method is public
    • isProtected

      boolean isProtected()
      Determine whether this method is protected.
      Returns:
      true if the method is protected
    • isPrivate

      boolean isPrivate()
      Determine whether this method is private.
      Returns:
      true if the method is private
    • isInner

      boolean isInner()
      Determine whether this method belongs to an inner type.
      Returns:
      true if the method belongs to an inner type
    • getClassType

      IJavaType getClassType()
      Get the type of the entity containing this method.
      Returns:
      the containing class type
    • getInnerClassSignatures

      List<String> getInnerClassSignatures()
      Retrieve the signatures of inner classes declared by this method.
      Returns:
      inner class signatures
    • getInnerClasses

      List<IJavaClass> getInnerClasses()
      Retrieve inner classes declared by this method.
      Returns:
      inner classes
    • getAnonymousClassSignatures

      List<String> getAnonymousClassSignatures()
      Retrieve the signatures of anonymous classes declared by this method.
      Returns:
      anonymous class signatures
    • getAnonymousClasses

      List<IJavaClass> getAnonymousClasses()
      Retrieve anonymous classes declared by this method.
      Returns:
      anonymous classes
    • getMethodAnnotations

      List<IJavaAnnotation> getMethodAnnotations()
      Retrieve method annotations.
      Returns:
      method annotations
    • getParameterAnnotations

      List<IJavaAnnotation> getParameterAnnotations(int index)
      Retrieve annotations for a parameter.
      Parameters:
      index - parameter index
      Returns:
      parameter annotations
    • setDefaultValue

      void setDefaultValue(IJavaExpression defaultValue)
      Set the default value associated with this method.
      Parameters:
      defaultValue - default value, or null
    • getDefaultValue

      IJavaExpression getDefaultValue()
      Get the default value provided by this method if there is one.

      Implementation note: currently used for annotation types only: if this object is an annotation method (i.e. it represents an attribute of an annotation type), this method will return the default value associated to this attribute, if there is one.

      Returns:
      a default value or null
    • getStatements

      List<IJavaStatement> getStatements()
      Walk the tree and get the ordered list of all (non-pseudo) statements that make up the method.
      Returns:
      ordered method statements
    • deleteStatement

      boolean deleteStatement(IJavaStatement stm)
      Delete a statement by reference. This method performs a deep search within the entire method. This works because no method should contain the same statement (in the sense, same reference) twice.
      Parameters:
      stm - the statement to delete
      Returns:
      true if the statement was found and deleted
    • generate

      void generate(JavaOutputSink out, boolean bodyOnly)
      Generate this method.
      Parameters:
      out - output sink
      bodyOnly - true to generate only the method body
    • generate

      void generate(JavaOutputSink out, int genkind)
      Generate this method.
      Parameters:
      out - output sink
      genkind - 0= regular method; 1= just the body of the method; 2= the method is a lambda
    • toFlatList

      List<IJavaStatement> toFlatList()
      Flatten the method body into a statement list.
      Returns:
      flattened statements
    • fromFlatList

      void fromFlatList(List<IJavaStatement> list)
      Replace the method body from a flat statement list.
      Parameters:
      list - statements to use as the method body
    • duplicate

      IJavaMethod duplicate()
      Description copied from interface: IJavaElement
      Duplicate this element.
      Specified by:
      duplicate in interface IJavaDecompilableElement
      Specified by:
      duplicate in interface IJavaElement
      Returns:
      a (possibly) duplicated object of the same type