Package gnu.bytecode

Class Method

java.lang.Object
gnu.bytecode.Method
All Implemented Interfaces:
AttrContainer, Member

public class Method extends Object implements AttrContainer, Member
Represents a method in a ClassType.

A Method contain a CodeAttr object; the interface for generating bytecode instructions is primarily in CodeAttr.

All the methods whose name start with compile_ are deprecated, and should not be used; use the methods in CodeAttrinstead.

  • Constructor Details

    • Method

      public Method(Method base, ClassType clas)
      A copy constructor, except you can override the declaring class. This can be used to improve binary compatibility by emitting method references where the declared class is the type of the receiver.
  • Method Details

    • getAttributes

      public final Attribute getAttributes()
      Description copied from interface: AttrContainer
      Get the (first) Attribute of this container.
      Specified by:
      getAttributes in interface AttrContainer
    • setAttributes

      public final void setAttributes(Attribute attributes)
      Description copied from interface: AttrContainer
      Set the (list of) Attributes of this container.
      Specified by:
      setAttributes in interface AttrContainer
    • getExceptionAttr

      public final ExceptionsAttr getExceptionAttr()
    • setExceptions

      public void setExceptions(short[] exn_indices)
    • setExceptions

      public void setExceptions(ClassType[] exn_types)
    • getCode

      public final CodeAttr getCode()
    • setStaticFlag

      public final void setStaticFlag(boolean is_static)
    • getStaticFlag

      public final boolean getStaticFlag()
      Specified by:
      getStaticFlag in interface Member
    • isAbstract

      public final boolean isAbstract()
    • isNative

      public final boolean isNative()
    • getModifiers

      public int getModifiers()
      Specified by:
      getModifiers in interface Member
    • setModifiers

      public void setModifiers(int modifiers)
    • getConstants

      public final ConstantPool getConstants()
      Specified by:
      getConstants in interface AttrContainer
    • pushScope

      public Scope pushScope()
    • reachableHere

      public final boolean reachableHere()
      True if control could reach here.
    • popScope

      public Scope popScope()
    • allocate_local

      @Deprecated public void allocate_local(Variable local)
      Deprecated.
      Allocate slots for a local variable (or parameter).
      Parameters:
      local - the variable we need to allocate
    • initCode

      public void initCode()
      Allocate a Code attribute, and prepare to generate code. Most code generators should use the startCode convenience method.
    • init_param_slots

      public void init_param_slots()
      Deprecated.
      Use startCode instead
    • startCode

      public CodeAttr startCode()
      Recommended method to create a new CodeAttr for this Method.
    • compile_checkcast

      public void compile_checkcast(Type type)
    • maybe_compile_checkcast

      public void maybe_compile_checkcast(Type type)
    • push_var

      public void push_var(Variable var)
      Deprecated.
      Comple code to push the contents of a local variable onto the statck.
      Parameters:
      var - The variable whose contents we want to push.
    • compile_push_value

      @Deprecated public void compile_push_value(Variable var)
      Deprecated.
    • compile_store_value

      @Deprecated public void compile_store_value(Variable var)
      Deprecated.
    • compile_push_this

      public void compile_push_this()
    • makeSignature

      public static String makeSignature(Type[] arg_types, Type return_type)
    • makeGenericSignature

      public static String makeGenericSignature(Type[] arg_types, Type return_type)
    • getSignature

      public String getSignature()
    • setSignature

      public void setSignature(String signature)
    • setSignature

      public void setSignature(int signature_index)
    • getAnnotation

      public <T extends Annotation> T getAnnotation(Class<T> clas)
      Specified by:
      getAnnotation in interface Member
    • getDeclaringClass

      public ClassType getDeclaringClass()
      Specified by:
      getDeclaringClass in interface Member
    • getReturnType

      public final Type getReturnType()
    • setReturnType

      public final void setReturnType(Type type)
    • getParameterTypes

      public final Type[] getParameterTypes()
    • getExceptions

      public final ClassType[] getExceptions()
    • getName

      public final String getName()
      Specified by:
      getName in interface Member
    • setName

      public final void setName(String name)
      Specified by:
      setName in interface Member
    • setName

      public final void setName(int name_index)
    • getNext

      public final Method getNext()
    • listParameters

      public void listParameters(StringBuffer sbuf)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • cleanupAfterCompilation

      public void cleanupAfterCompilation()