Package serp.bytecode

Class ClassConstantInstruction


  • public class ClassConstantInstruction
    extends java.lang.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.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private BCField addClassField​(java.lang.String name)
      Adds a static field to hold the loaded class constant.
      private BCMethod addClassLoadMethod()
      Adds the standard class$ method used inernally by classes to load class constants for object types.
      private static java.lang.Class getWrapperClass​(java.lang.String name)
      Return the wrapper type for the given primitive class, or null if the given name is not a primitive type.
      Instruction setClass​(java.lang.Class type)
      Set the type of class being loaded.
      Instruction setClass​(java.lang.String name)
      Set the type of class being loaded.
      Instruction setClass​(BCClass type)
      Set the type of class being loaded.
      private void setClassName​(java.lang.String name, java.lang.Class wrapper)
      Set the name of the class to load.
      private void setObject​(java.lang.String name)
      Adds fields and methods as necessary to load a class constant of an object type.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • _params

        private static final java.lang.Class[] _params
      • _wrappers

        private static final java.util.Map _wrappers
      • _code

        private Code _code
      • _invalid

        private boolean _invalid
    • Method Detail

      • setClass

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

        public Instruction setClass​(java.lang.Class type)
        Set the type of class being loaded.
        Returns:
        the first Instruction of the block added by setting the type
        Throws:
        java.lang.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:
        java.lang.IllegalStateException - if type has already been set
      • setClassName

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

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

        private BCField addClassField​(java.lang.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 java.lang.Class getWrapperClass​(java.lang.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.