Class ClassFileWriter.ConstPoolWriter

  • Enclosing class:
    ClassFileWriter

    public static final class ClassFileWriter.ConstPoolWriter
    extends Object
    Constant Pool.
    • Field Detail

      • startPos

        protected int startPos
      • num

        protected int num
    • Method Detail

      • addClassInfo

        public int[] addClassInfo​(String[] classNames)
        Makes CONSTANT_Class_info objects for each class name.
        Returns:
        an array of indexes indicating CONSTANT_Class_infos.
      • addClassInfo

        public int addClassInfo​(String jvmname)
        Adds a new CONSTANT_Class_info structure.

        This also adds a CONSTANT_Utf8_info structure for storing the class name.

        Parameters:
        jvmname - the JVM-internal representation of a class name. e.g. java/lang/Object.
        Returns:
        the index of the added entry.
      • addClassInfo

        public int addClassInfo​(int name)
        Adds a new CONSTANT_Class_info structure.
        Parameters:
        name - name_index
        Returns:
        the index of the added entry.
      • addNameAndTypeInfo

        public int addNameAndTypeInfo​(String name,
                                      String type)
        Adds a new CONSTANT_NameAndType_info structure.
        Parameters:
        name - name_index
        type - descriptor_index
        Returns:
        the index of the added entry.
      • addNameAndTypeInfo

        public int addNameAndTypeInfo​(int name,
                                      int type)
        Adds a new CONSTANT_NameAndType_info structure.
        Parameters:
        name - name_index
        type - descriptor_index
        Returns:
        the index of the added entry.
      • addFieldrefInfo

        public int addFieldrefInfo​(int classInfo,
                                   int nameAndTypeInfo)
        Adds a new CONSTANT_Fieldref_info structure.
        Parameters:
        classInfo - class_index
        nameAndTypeInfo - name_and_type_index.
        Returns:
        the index of the added entry.
      • addMethodrefInfo

        public int addMethodrefInfo​(int classInfo,
                                    int nameAndTypeInfo)
        Adds a new CONSTANT_Methodref_info structure.
        Parameters:
        classInfo - class_index
        nameAndTypeInfo - name_and_type_index.
        Returns:
        the index of the added entry.
      • addInterfaceMethodrefInfo

        public int addInterfaceMethodrefInfo​(int classInfo,
                                             int nameAndTypeInfo)
        Adds a new CONSTANT_InterfaceMethodref_info structure.
        Parameters:
        classInfo - class_index
        nameAndTypeInfo - name_and_type_index.
        Returns:
        the index of the added entry.
      • addMethodHandleInfo

        public int addMethodHandleInfo​(int kind,
                                       int index)
        Adds a new CONSTANT_MethodHandle_info structure.
        Parameters:
        kind - reference_kind such as REF_invokeStatic.
        index - reference_index.
        Returns:
        the index of the added entry.
        Since:
        3.17.1
      • addMethodTypeInfo

        public int addMethodTypeInfo​(int desc)
        Adds a new CONSTANT_MethodType_info structure.
        Parameters:
        desc - descriptor_index.
        Returns:
        the index of the added entry.
        Since:
        3.17.1
      • addInvokeDynamicInfo

        public int addInvokeDynamicInfo​(int bootstrap,
                                        int nameAndTypeInfo)
        Adds a new CONSTANT_InvokeDynamic_info structure.
        Parameters:
        bootstrap - bootstrap_method_attr_index.
        nameAndTypeInfo - name_and_type_index.
        Returns:
        the index of the added entry.
        Since:
        3.17.1
      • addStringInfo

        public int addStringInfo​(String str)
        Adds a new CONSTANT_String_info structure.

        This also adds a new CONSTANT_Utf8_info structure.

        Returns:
        the index of the added entry.
      • addIntegerInfo

        public int addIntegerInfo​(int i)
        Adds a new CONSTANT_Integer_info structure.
        Returns:
        the index of the added entry.
      • addFloatInfo

        public int addFloatInfo​(float f)
        Adds a new CONSTANT_Float_info structure.
        Returns:
        the index of the added entry.
      • addLongInfo

        public int addLongInfo​(long l)
        Adds a new CONSTANT_Long_info structure.
        Returns:
        the index of the added entry.
      • addDoubleInfo

        public int addDoubleInfo​(double d)
        Adds a new CONSTANT_Double_info structure.
        Returns:
        the index of the added entry.
      • addUtf8Info

        public int addUtf8Info​(String utf8)
        Adds a new CONSTANT_Utf8_info structure.
        Returns:
        the index of the added entry.