Class ConstantPool

    • Field Detail

      • tableSize

        🡇     🗕  🗗  🗖
        public final int tableSize
        This is identical to tags.size() - which is necessarily the same as values.size(), indices.size() and even dereferencedValues.size().

        All four instance lists in this class are "Parallel Lists". This means that the data contained by an element in any one of the lists is data that is pertinent to a piece of data in all three of the other lists - as long as that datum is located at the exact same list index of its other list.

        Notes on the Lists
        1. Note that though both Java Array's and List's have an index that starts at zero, the values which is stored at zero-position in each of the following lists: tags, values, indices & dereferencedValues is not considered one of the Constant-Pool Constants.

        2. Java's Constant-Pool has a few quirks, one of which is that when a Table-Constant has a size of 8-Bytes - which is referring to, specifically, Long and Double constants - the Constant-Number which would otherwise immediately follow these 8-Byte values are skipped!. By the term "Constant Number", we are just referring to the List-Index for these four Parallel Lists.

          To restate the above point, any Table-Constant List-Position which is immediately after a Long-Constant or a Double-Constant will always be null. Please review the Code-Snippet below, and pay close attention to when the contents of one of this class' Parallel-Lists contain null.

        ConstantPool cp = new ConstantPool(bArr);
        
        // If the following loop prints anything, it can only print 'null'
        for (Integer i : cp.indicesGroupBy.get(ConstantPool.TAG_LONG))
            if ((i + 1) < cp.tableSize)
                System.out.println(cp.values.get(i + 1));
        
        Code:
        Exact Field Declaration Expression:
         public final int tableSize;
        
      • tableSizeBytes

        🡅  🡇     🗕  🗗  🗖
        public final int tableSizeBytes
        The value stored in this public final constant shall be precisely equal to the Byte-Number, within the input byte[]-Array, where the Access-Flags Unsigned-Integer starts minus 10.

        To explain, the Java Constant-Pool is the first Table-Structure inside of any valid Java '.class' file. The Constant-Pool begins on byte #10 of the byte[]-Array representing a '.class' File. Bytes #8 and #9 contain the size of the table, which have been stored in the array to reveal precisely how many constants should be read from this Constants-Table.

        In any standard '.class' File, a Two-Byte Unsigned Integer that contains the Bit-Mask for the list of Access-Flags immediately follows the Constant-Pool Table. So, when it is said that:

        • The value stored in 'tableSizeBytes' is the same as the location of the first Unsigned-Byte of the Access-Flags Bit-Mask, it is because that Bit-Mask is the very next item after the Constant-Pool within the original '.class' File's byte[]-Array.

        • The reason '10' would actually need to be added to 'tableSizeBytes' to retrieve that Array-Index, is due to the fact that within the confines of any Java '.class'-File represented as a byte[]-Array, the Table / Pool itself does not begin until the 10th byte of the file!

        final byte[]        bArr    = FileRW.readBinary("MyProject/MyPackage/MyClass.class");
        final ConstantPool  cp      = new ConstantPool(bArr);
        final int           pos     = cp.tableSizeBytes + 10;
        final int           flags   = ((bArr[pos] & 0xFF) << 8) | (bArr[pos + 1] & 0xFF);
        
        System.out.println("Access Flags Bit-Mask: " + Integer.toBinaryString(flags));
        
        Code:
        Exact Field Declaration Expression:
         public final int tableSizeBytes;
        
      • tags

        🡅  🡇     🗕  🗗  🗖
        public final ReadOnlyList<java.lang.Byte> tags
        tagNames List
        A Java '.class' File's Constant-Pool is actually just a table, which is saved as a sequential list of number. Each constant which is defined in this table has at the very beginning of its definition a single one-byte number that defines what "type" or "kind" of constant it is. The types of constants available may all be viewed inside the definition for this Class' Field tagNames. Click on tht link to see the list of all tags.

        tagNames is a public, static and final-ReadOnly that contains exactly 17, non-null, Category-Names for the 'type' or 'kind' of constants defined in a Constant-Pool. Because the Constant-Pool has been apart of Java 'class' Files since the JDK 1.0 was released, it isn't so easy to up and change the definitions of used by these tables. As such, explaining why the types that would be numbered 2, 13 and 14 are undefined, but suffice it to say, they the list indices in the Tag-Names table are, indeed, null.

        'tags' (this) List
        This field is a non-static - "Instance Field" - that corresponds to whatever '.class' File's Constant-Pool was parsed to build the instance that holds this public, final (and Read-Only) field.

        The values for the tagNames-List are loaded, once, by the Class-Loader (because that's how static-constant fields work!). The contents of this field are loaded every time a new instance of this class is built by this class' constructor.

        The only values that may be stored into this table are the list of values from the tagNames table which are non-null! That list is precisely equal to the numbers between 1 and 20 - except 2, 13 and 14
        See Also:
        tagNames
        Code:
        Exact Field Declaration Expression:
         public final ReadOnlyList<Byte> tags;
        
      • values

        🡅  🡇     🗕  🗗  🗖
        public final ReadOnlyList<java.lang.Object> values
        A Java Constant-Pool stores values. These values have "types" or "kinds" - which are all saved into the very first byte of the Constant itself. For any given '.class' File, if that file's Constant-Pool is loaded into an instance of this class, those "types" or "kids" are saved into the tags Read-Only List. That list is considered a Parallel-Array to this List, and its length shall always be identical to the length of this List.

        This contents of the 'values' Read-Only List are the constants, themselves.

        The Types in 'values':
        The ConstantPool field 'values' is declared as a ReadOnlyList<Object>. What are the types of these Object's in the list? The following table shall present the exact Java-Type that should be expected in the 'values' list, listed according to the Type-Kind that would be found in the tags Parallel-Array Index-Location corresponding to the same element in this, the 'values' list. The following tables will hopefully make all of this more clear.

        If: tags.get(1) == TAG_METHOD_REF Then: values.get(1) instanceof Ret2 <Integer, Integer>
        If: tags.get(3) == TAG_UTF_8 Then: values.get(3) instanceof java.lang.String


        Note that in this table, all java.lang.Integer (other than the type for Tag-Kind TAG_INTEGER itself), the "integer" is intended to signify an "Index-Pointer" (also simply called a "Table-Index") which points back into another cell inside the Constant-Pool Table.

        Furthermore, any instance of Ret2<Integer, Integer> is intended to signify a "Pointer-Pair" - which is just two separate Pointer-Indices back into the Constant-Pool Table.

        Tag-Kind Java-Type Purpose
        01: TAG_UTF_8 java.lang.String UTF-8 String-Constant
        03: TAG_INTEGER java.lang.Integer Actual 'int' Constant
        04: TAG_FLOAT java.lang.Float Actual 'float' Constant
        05: TAG_LONG java.lang.Long Actual 'long' Constant
        06: TAG_DOUBLE java.lang.Double Actual 'double' Constant
        07: TAG_CLASS java.lang.Integer Table-Pointer
        08: TAG_STRING java.lang.Integer Table-Pointer
        09: TAG_FIELD_REF Ret2<Integer, Integer> Table-Pointer Pair
        10: TAG_METHOD_REF Ret2<Integer, Integer> Table-Pointer Pair
        11: TAG_INTERFACE_METHOD_REF Ret2<Integer, Integer> Table-Pointer Pair
        12: TAG_NAME_AND_TYPE Ret2<Integer, Integer> Table-Pointer Pair
        15: TAG_METHOD_HANDLE Ret2<Byte, Integer> Kind & Table-Pointer
        16: TAG_METHOD_TYPE java.lang.Integer Table-Pointer
        17: TAG_DYNAMIC Ret2<Integer, Integer> Table-Pointer Pair
        18: TAG_INVOKE_DYNAMIC Ret2<Integer, Integer> Table-Pointer Pair
        19: TAG_MODULE java.lang.Integer Table-Pointer
        20: TAG_PACKAGE java.lang.Integer Table-Pointer
        Code:
        Exact Field Declaration Expression:
         public final ReadOnlyList<Object> values;
        
      • dereferencedValues

        🡅  🡇         External-Java:    🗕  🗗  🗖
        public final ReadOnlyList<java.lang.Object> dereferencedValues
        The values, but they have been "De-Referenced." De-Referencing the values means removing any and all Table-Index "pointers" which are present inside the Constants within the table, and replacing them with the instantiated objects that have been designed for them.

        Dereferenced Types:
        The following table shall exhibit which types are actually present inside the dereferencedValues ReadOnlyList<Object>. The meaning of "dereferenced" is such that any Constants which are either, solely, Table-Index Pointers to other actual Constants in the Table / Pool - or are combination / pairs of Table-Index Pointers - are instantiated & converted into the actual Java Objects / POJO's which were explicitly designed to represent the data to which these "Reference-Based" constants are pointing.

        If that sounds like a mouthful, the concept (which is actually extremely simple), is delineated in the "Types Table" below. The Java POJO-Types associated with the Constant-Pool's "Reference Based" constants are listed here:

        Tag-Kind 'values' Type 'dereferencedValues' POJO
        9: TAG_FIELD_REF Ret2<Integer, Integer> ConstantPool.Reference
        10: TAG_METHOD_REF Ret2<Integer, Integer> ConstantPool.Reference
        11: TAG_INTERFACE_METHOD_REF Ret2<Integer, Integer> ConstantPool.Reference
        15: TAG_METHOD_HANDLE Ret2<Byte, Integer> ConstantPool.MethodHandle
        17: TAG_DYNAMIC Ret2<Integer, Integer> ConstantPool.Dynamic
        18: TAG_INVOKE_DYNAMIC Ret2<Integer, Integer> ConstantPool.Dynamic


        Simple De-Referenced POJO's
        The following five Tag-Kind's, when present in the dereferencedValues list, will have had their Integer-Values replaced by the UTF-8 String-Values to which they are pointing:

        Code:
        Exact Field Declaration Expression:
         @LinkJavaSource(handle="DereferencedValue")
             public final ReadOnlyList<Object> dereferencedValues;
        
      • indicesGroupBy

        🡅  🡇     🗕  🗗  🗖
        public final ReadOnlyList<ReadOnlyList<java.lang.Integer>> indicesGroupBy
        This instance field is a Map-Like List. Specifically, it is a List which functions as a typical Java Map whose May "keys" are the Tag-Bytes / Tag-Kinds, while simultneoously at the same time, a Tag-Byte is also the List Index-Pointer into this ReadOnlyList.

        Unused Constant-Pool Tags:
        Their are exactly 21 - 4 "types" or "kinds" of constants which may be placed in a Java '.class' File Constant-Pool. 21 is because each of these Type-Kinds is associated with a natural number, beginning with 0. -4 is because the natural number's 0, 2, 13 and 14 are actually not associated with a Constant-Pool 'kind'.

        "Why" those four are skipped probably goes back to 1995 when these files were first written. Rather than explain why, instead, just know that when the Instance Field 'indicesGroupBy' is accessed using a List-Index of 0, 2, 13 and 14, null shall always be returned.

        2-Dimensional List:
        Since 21 - 4 is, indeed, 17 there will be exactly '17' non-null values residing within the 'indicesGroupBy' list. Each index into the Group-By 2-Dimensional 'List' which is non-null shall hold a single, 1-Dimensional, 'List' of Constant-Pool indices.

        The indices which reside in each of these 1-Dimensional 'Lists" are simply pointers into the Constant-Pool table. The indices are sorted acording to their "Type-Kind", and are placed into the 2-D List-Location whose index matches each of the "Type-Kinds" of the 1-D Indice-Lists.

        Group-By Exampe:
        The following code will hopefully help elucidate the "incantation" printed in the text just above:

        Example:
        byte[]       bArr   = FileRW.readData("MyProject/MyPackage/MyClass.class");
        ConstantPool cp     = new ConstantPool(bArr);
        
        for (Integer i : cp.indicesGroupBy.get(ConstantPool.TAG_UTF8))
        
            System.out.println(
                "constantPool.tags(" + i + "):   '" + ConstantPool.tagNames(cp.tags(i)) + "'\n" +
                "constantPool.values(" + i + "): '" + cp.values(i) + '\''
            );
        
        // Prints All UTF-8 Constants:
        // 
        // ConstantPool.tags(1):   'UTF-8'
        // ConstantPool.values(1): "Some UTF-8 String-Constant from the Pool"
        // ConstantPool.tags(2):   'UTF-8'
        // ConstantPool.values(2): "Another UTF-8 String-Constant from the Pool"
        // 
        // ... And so on and so forth ...
        


        Null-Safety and Unused-Tags:
        Any index into the Top-Level Group-By List whose tag is valid and is allowed for associating a Constant-Pool Type-Kind will never be assigned null. While the following was just explained in this comment several lines above, and holds as per this example below. Indices 0, 2, 13 and 14 are always empty, and attempting to retrieve a 1-D List of numbers from this table shall always fail, and produce null, instead!

        Example:
        // Indices 0, 2, 13 and 14 are always empty.  Referencing those indices will produce null.
        
        byte[]       bArr   = FileRW.readData("MyProject/MyPackage/MyClass.class");
        ConstantPool cp     = new ConstantPool(bArr);
        
        if (cp.indicesGroupingBy.get(2) == null)
            // This Statement is guaranteed to execute for all valid ConstantPool instances
        
        if (cp.indicesGroupingBy.get(13) != null)
            // This Statement can NEVER execute, this code is unreachable!
        

        However, all other indices between '1' ... '20' will never produce null! If there is a tag for a Type-Kind that was never used by the ConstantPool table - meaning that there aren't any of "those kinds" of constant to have been identified by the parser in a particular table, then the 2-D Group-By List will return an Empty-Non-Null 1-D 'List', rather than null.

        For a better understanding of this concept, please review the following code snippet below. Here, a less frequently Constant-Pool Type-Kind tag is retrieved from the 2-D Lookup-Table. If the '.class'-File which was used to load 'bArr' was brief and didn't have ny "Invoke-Dynamic" constants, the code below is, indeed, null-safe and will not throw any NullPointerException's.

        Example:
        // The Tag Type-Kind for "Invoke-Dynamic" is less commonly used tag. 
        ReadOnlyList<Integer> invokeDynameIndicesList = 
             cp.indicesGroupingBy.get(ConstantPool.TAG_INVOKE_DYNAMIC);
        
        // If there are zero such constants, the above list will be EMPTY, NOT NULL !
        System.out.println(
             "Num 'InvokeDynamic' Constants in the Pool: " +
             invokeDynamicIndicesList.size()
        );
        
        // It is likely that the above statement will print '0'
        // It is NOT POSSIBLE for the code above to throw NPE, NullPointerException
        
        Code:
        Exact Field Declaration Expression:
         public final ReadOnlyList<ReadOnlyList<Integer>> indicesGroupBy;
        
      • tagNames

        🡅  🡇         External-Java:    🗕  🗗  🗖
        public static final ReadOnlyList<java.lang.String> tagNames
        This is the complete list of available Constant-Pool 'types' or 'kinds'. Each entry in a Java '.class'-File's Constant-Pool has a type which is stored in the first byte of the constant. That byte must be one of the 17, non-null, types or kinds which are specified in this list! Please review the exact names of the kinds of constants which may be defined inside of a Java Constant-Pool in the list below.

        tags List
        When this class is used to parse the Constant-Pool of a Java '.class' File, to create an instance of this class, that instance shall have two public and final-ReadOnly Lists that store the information needed for each constant. Those two Lists are considered "Parallel Arrays" (or, preferably, "Parallel-Lists"). They are Instance-Fields, and they are named: tags and values .

        The String's listed in this table will correspond to the names of the 'kinds' or 'types' of constants in the instance. The tags Parallel-Array contains that kind, specifying the Constant's type. The name for that contants type/kind may be looked up in this static, final and ReadOnly lookup-table list.

        Tag #5 is stored in List-Index #5; while Tag #10 is saved to List-Index #10, and so on, and so forth...

        You may view the contents of this Lookup-Table by either clicking the "External Java" Button (directly above) to see the actual Data-File which loads this static, final Read-Only Lookup-Table, or by reviewing the following HTML-Table.

        This ReadOnlyList contains exactly 21 elements, and these elements are listed, explicitly, below:

        Tag Index Name as String  
        0UNUSED, null
        1: TAG_UTF_8 "UTF-8"
        2 UNUSED, null
        3: TAG_INTEGER "Integer"
        4: TAG_FLOAT "Float"
        5: TAG_LONG "Long"
        6: TAG_DOUBLE "Double"
        7: TAG_CLASS "Class"
        8: TAG_STRING "String"
        9: TAG_FIELD_REF "FieldRef"
        10: TAG_METHOD_REF "MethodRef"
        11: TAG_INTERFACE_METHOD_REF "InterfaceMethodRef"
        12: TAG_NAME_AND_TYPE "NameAndType"
        13 UNUSED, null
        14 UNUSED, null
        15: TAG_METHOD_HANDLE "MethodHandle"
        16: TAG_METHOD_TYPE "MethodType"
        17: TAG_DYNAMIC "Dynamic"
        18: TAG_INVOKE_DYNAMIC "InvokeDynamic"
        19: TAG_MODULE "Module"
        20: TAG_PACKAGE "Package"
        See Also:
        List of Types/Kinds for each Constant, List of Values for each Constant
        Code:
        Exact Field Declaration Expression:
         @LinkJavaSource(handle="ConstantPoolData", entity=FIELD, name="tagNames")
             public static final ReadOnlyList<String> tagNames = dataFileR2.GET(1);
        
      • tagWidthBytes

        🡅  🡇         External-Java:    🗕  🗗  🗖
        public static final ReadOnlyList<java.lang.Byte> tagWidthBytes
        The values saved into this table specify how many bytes of data are used for each of the 17 available constants.

        Likely, this public, static and final-ReadOnly table is of little use to the end user of this ConstantPool class. However, with the advent of the 'ReadOnly'-Package, leaving this as a public list / table certainly isn't causing anybody any harm.

        You may view the contents of this Lookup-Table by either clicking the "External Java" Button (directly above) to see the actual Data-File which loads this static, final Read-Only Lookup-Table, or by reviewing the following HTML-Table.

        This ReadOnlyList contains exactly 21 elements, and these elements are listed, explicitly, below:

        Tag Index Width  
        0UNUSED, null
        1: TAG_UTF_8 Variable-Width
        2 UNUSED, null
        3: TAG_INTEGER 4 Bytes
        4: TAG_FLOAT 4 Bytes
        5: TAG_LONG 8 Bytes
        6: TAG_DOUBLE 8 Bytes
        7: TAG_CLASS 2 Bytes
        8: TAG_STRING 2 Bytes
        9: TAG_FIELD_REF 4 Bytes
        10: TAG_METHOD_REF 4 Bytes
        11: TAG_INTERFACE_METHOD_REF 4 Bytes
        12: TAG_NAME_AND_TYPE 4 Bytes
        13 UNUSED, null
        14 UNUSED, null
        15: TAG_METHOD_HANDLE 3 Bytes
        16: TAG_METHOD_TYPE 2 Bytes
        17: TAG_DYNAMIC 4 Bytes
        18: TAG_INVOKE_DYNAMIC 4 Bytes
        19: TAG_MODULE 2 Bytes
        20: TAG_PACKAGE 2 Bytes
        Code:
        Exact Field Declaration Expression:
         @LinkJavaSource(handle="ConstantPoolData", entity=FIELD, name="tagWidthBytes")
             public static final ReadOnlyList<Byte> tagWidthBytes = dataFileR2.GET(2);
        
      • TAG_UTF_8

        🡅  🡇     🗕  🗗  🗖
        public static final byte TAG_UTF_8
        Tag byte indicating the next constant in the table is a UTF-8 encoded String. Typically used for identifiers such as names or other textual data.
        See Also:
        Constant Field Values
        Code:
        Exact Field Declaration Expression:
         public static final byte TAG_UTF_8 = 1;
        
      • TAG_INTEGER

        🡅  🡇     🗕  🗗  🗖
        public static final byte TAG_INTEGER
        Tag byte indicating the next constant in the table is a 32-bit integer. Used for numeric constants within the constant pool.
        See Also:
        Constant Field Values
        Code:
        Exact Field Declaration Expression:
         public static final byte TAG_INTEGER = 3;
        
      • TAG_FLOAT

        🡅  🡇     🗕  🗗  🗖
        public static final byte TAG_FLOAT
        Tag byte indicating the next constant in the table is a 32-bit floating-point number. Represents constants of the float data type.
        See Also:
        Constant Field Values
        Code:
        Exact Field Declaration Expression:
         public static final byte TAG_FLOAT = 4;
        
      • TAG_LONG

        🡅  🡇     🗕  🗗  🗖
        public static final byte TAG_LONG
        Tag byte indicating the next constant in the table is a 64-bit long integer. Represents constants of the long data type.
        See Also:
        Constant Field Values
        Code:
        Exact Field Declaration Expression:
         public static final byte TAG_LONG = 5;
        
      • TAG_DOUBLE

        🡅  🡇     🗕  🗗  🗖
        public static final byte TAG_DOUBLE
        Tag byte indicating the next constant in the table is a 64-bit double-precision floating-point number. Represents constants of the double data type.
        See Also:
        Constant Field Values
        Code:
        Exact Field Declaration Expression:
         public static final byte TAG_DOUBLE = 6;
        
      • TAG_CLASS

        🡅  🡇     🗕  🗗  🗖
        public static final byte TAG_CLASS
        Tag byte indicating the next constant in the table is a class reference. Represents a Class or interface type.
        See Also:
        Constant Field Values
        Code:
        Exact Field Declaration Expression:
         public static final byte TAG_CLASS = 7;
        
      • TAG_STRING

        🡅  🡇     🗕  🗗  🗖
        public static final byte TAG_STRING
        Tag byte indicating the next constant in the table is a String reference. The referenced String is stored elsewhere in the constant pool.
        See Also:
        Constant Field Values
        Code:
        Exact Field Declaration Expression:
         public static final byte TAG_STRING = 8;
        
      • TAG_FIELD_REF

        🡅  🡇     🗕  🗗  🗖
        public static final byte TAG_FIELD_REF
        Tag byte indicating the next constant in the table is a reference to a field. Used for fields within a Class or interface.
        See Also:
        Constant Field Values
        Code:
        Exact Field Declaration Expression:
         public static final byte TAG_FIELD_REF = 9;
        
      • TAG_METHOD_REF

        🡅  🡇     🗕  🗗  🗖
        public static final byte TAG_METHOD_REF
        Tag byte indicating the next constant in the table is a reference to a method. Refers to methods defined in a Class.
        See Also:
        Constant Field Values
        Code:
        Exact Field Declaration Expression:
         public static final byte TAG_METHOD_REF = 10;
        
      • TAG_INTERFACE_METHOD_REF

        🡅  🡇     🗕  🗗  🗖
        public static final byte TAG_INTERFACE_METHOD_REF
        Tag byte indicating the next constant in the table is a reference to an interface method. Refers to methods declared within an interface.
        See Also:
        Constant Field Values
        Code:
        Exact Field Declaration Expression:
         public static final byte TAG_INTERFACE_METHOD_REF = 11;
        
      • TAG_NAME_AND_TYPE

        🡅  🡇     🗕  🗗  🗖
        public static final byte TAG_NAME_AND_TYPE
        Tag byte indicating the next constant in the table is a name-and-type descriptor. Encodes the name and type of a field or method.
        See Also:
        Constant Field Values
        Code:
        Exact Field Declaration Expression:
         public static final byte TAG_NAME_AND_TYPE = 12;
        
      • TAG_METHOD_HANDLE

        🡅  🡇     🗕  🗗  🗖
        public static final byte TAG_METHOD_HANDLE
        Tag byte indicating the next constant in the table is a method handle. Represents a reference to a method handle for dynamic invocation.
        See Also:
        Constant Field Values
        Code:
        Exact Field Declaration Expression:
         public static final byte TAG_METHOD_HANDLE = 15;
        
      • TAG_METHOD_TYPE

        🡅  🡇     🗕  🗗  🗖
        public static final byte TAG_METHOD_TYPE
        Tag byte indicating the next constant in the table is a method type. Encodes the method's descriptor, including parameter and return types.
        See Also:
        Constant Field Values
        Code:
        Exact Field Declaration Expression:
         public static final byte TAG_METHOD_TYPE = 16;
        
      • TAG_DYNAMIC

        🡅  🡇     🗕  🗗  🗖
        public static final byte TAG_DYNAMIC
        Tag byte indicating the next constant in the table is a dynamic constant. Represents a runtime-computed constant, often linked to lambdas or invokedynamic instructions.
        See Also:
        Constant Field Values
        Code:
        Exact Field Declaration Expression:
         public static final byte TAG_DYNAMIC = 17;
        
      • TAG_INVOKE_DYNAMIC

        🡅  🡇     🗕  🗗  🗖
        public static final byte TAG_INVOKE_DYNAMIC
        Tag byte indicating the next constant in the table is an invoke-dynamic constant. Represents a bootstrap method and dynamic call site for runtime resolution.
        See Also:
        Constant Field Values
        Code:
        Exact Field Declaration Expression:
         public static final byte TAG_INVOKE_DYNAMIC = 18;
        
      • TAG_MODULE

        🡅  🡇     🗕  🗗  🗖
        public static final byte TAG_MODULE
        Tag byte indicating the next constant in the table is a module reference. Encodes the name of a module within the constant pool.
        See Also:
        Constant Field Values
        Code:
        Exact Field Declaration Expression:
         public static final byte TAG_MODULE = 19;
        
      • TAG_PACKAGE

        🡅  🡇     🗕  🗗  🗖
        public static final byte TAG_PACKAGE
        Tag byte indicating the next constant in the table is a package reference. Encodes the name of a package within the constant pool.
        See Also:
        Constant Field Values
        Code:
        Exact Field Declaration Expression:
         public static final byte TAG_PACKAGE = 20;
        
    • Constructor Detail

      • ConstantPool

        🡅  🡇         External-Java:          🗕  🗗  🗖
        public ConstantPool​(byte[] bArr)
        Constructs an intance of this class using a pre-loaded byte[]-Array. Here below is an exmple of loading a Java '.class' File into memory, and invoking this constructor in order to instantiate an instance of this class.

        In this exmple, the names of all Method References and Interface-Method References are printed out to the terminal.

        Example:
        byte[]          bArr    = FileRW.readData("MyProject/MyPackage/MyClass.class");
        ConstantPool    cp      = new ConstantPool(bArr);
        
        cp.allMethodNames().forEach(System.out::println);
        
        Parameters:
        bArr - A Class-File which has been loaded from disk into a memory, as a Java byte[] Array.
    • Method Detail

      • toString

        🡅  🡇         External-Java:    🗕  🗗  🗖
        public java.lang.String toString()
        Converts the contents of an instance of this class into a User-Readable String.
        Overrides:
        toString in class java.lang.Object
        Returns:
        A Java-String which explicates a Java '.class' File's Constant-Pool.
        Code:
        Exact Method Body:
         return CPToString.str(this.tags, this.values, this.indicesGroupBy);
        
      • equals

        🡅  🡇     🗕  🗗  🗖
        public boolean equals​(java.lang.Object other)
        Checks for equality with another instance of ConstantPool.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        other - Any Java-Object, but only an instance of ConstantPool whose tags and values Array-Lists are equal will cause this method to return TRUE.
        Returns:
        TRUE if and only if the contents 'this' instance of Constant-Pool equals those found in parameter 'other'
        Code:
        Exact Method Body:
         if (! (other instanceof ConstantPool)) return false;
        
         ConstantPool o = (ConstantPool) other;
        
         return
                 this.tags.equals(o.tags)
             &&  this.values.equals(o.values)
             &&  this.indices.equals(o.indices);
        
      • hashCode

        🡅  🡇     🗕  🗗  🗖
        public int hashCode()
        Java's traditional Hash-Code generator Method.
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        a (plausibly unique) Hash-Code, which may be used for placing instances of ConstantPool into Hash-Tables.
        Code:
        Exact Method Body:
         // No, this isn't any good... To-Do: Worry about it...
         int hash = 0;
         for (Byte tag : this.tags) if (tag != null) hash += tag;
         return hash;
        
      • allFieldNames

        🡅  🡇         External-Java:    🗕  🗗  🗖
        public java.util.stream.Stream<java.lang.String> allFieldNames()
        Retrieves the names of all Field-References which were listed in the Constant-Pool table that was used to build 'this' instance.
        Returns:
        A Java-Stream containing the names of any / all fields from the table.
        Code:
        Exact Method Body:
         return AllNames.getAllFieldNames(
             this.indicesGroupBy.get(ConstantPool.TAG_FIELD_REF),
             this.values
         );
        
      • allMethodNames

        🡅  🡇         External-Java:    🗕  🗗  🗖
        public java.util.stream.Stream<java.lang.String> allMethodNames()
        Retrieves the names of all Method-References and Interface-Method-References which were listed in the Constant-Pool that was used to build 'this' instance.

        Type-Kinds Available:

        Returns:
        A Java-Stream<String> containing the names of any / all methods and "Method References" from the Constant-Pool Table.
        Code:
        Exact Method Body:
         return AllNames.getAllMethodNames(
             this.indicesGroupBy.get(ConstantPool.TAG_METHOD_REF),
             this.indicesGroupBy.get(ConstantPool.TAG_INTERFACE_METHOD_REF),
             this.values
         );