Package serp.bytecode

Class ClassConstantInstruction

java.lang.Object
serp.bytecode.ClassConstantInstruction

public class ClassConstantInstruction extends Object
Pseudo-instruction used to place Class objects onto the stack. This logical instruction may actually involve a large chunk of code, and may even add static synthetic fields and methods to the owning class. Therefore, once the type of class being loaded is set, it cannot be changed. Also, this instruction is invalid as the target of any jump instruction or exception handler.
  • Field Details

    • _params

      private static final Class[] _params
    • _wrappers

      private static final Map _wrappers
    • _ins

      private Instruction _ins
    • _code

      private Code _code
    • _class

      private BCClass _class
    • _invalid

      private boolean _invalid
  • Constructor Details

  • Method Details

    • setClass

      public Instruction setClass(String name)
      Set the type of class being loaded.
      Returns:
      the first Instruction of the block added by setting the type
      Throws:
      IllegalStateException - if type has already been set
    • setClass

      public Instruction setClass(Class type)
      Set the type of class being loaded.
      Returns:
      the first Instruction of the block added by setting the type
      Throws:
      IllegalStateException - if type has already been set
    • setClass

      public Instruction setClass(BCClass type)
      Set the type of class being loaded.
      Returns:
      the first Instruction of the block added by setting the type
      Throws:
      IllegalStateException - if type has already been set
    • setClassName

      private void setClassName(String name, Class wrapper)
      Set the name of the class to load.
    • setObject

      private void setObject(String name)
      Adds fields and methods as necessary to load a class constant of an object type.
    • addClassField

      private BCField addClassField(String name)
      Adds a static field to hold the loaded class constant.
    • addClassLoadMethod

      private BCMethod addClassLoadMethod()
      Adds the standard class$ method used inernally by classes to load class constants for object types.
    • getWrapperClass

      private static Class getWrapperClass(String name)
      Return the wrapper type for the given primitive class, or null if the given name is not a primitive type. The given name should be in external form.