Class ConstantPool


  • public class ConstantPool
    extends java.lang.Object
    A representation of the data in a Java class-file's Constant Pool. Constant Pool entries are managed by reference counting.
    • Constructor Summary

      Constructors 
      Constructor Description
      ConstantPool​(ClassFile classFile, CpInfo[] cpInfo)
      Ctor, which initializes Constant Pool using an array of CpInfo.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int addEntry​(CpInfo entry)
      Add an entry to the constant pool and return its index.
      int addUtf8Entry​(java.lang.String s)  
      void decRefCount​(int i)
      Decrement the reference count for the specified element, blanking if Utf and refs are zero.
      java.util.Enumeration elements()
      Return an Enumeration of all Constant Pool entries.
      CpInfo getCpEntry​(int i)
      Return the specified Constant Pool entry.
      void incRefCount​(int i)
      Increment the reference count for the specified element.
      int length()
      Return the Constant Pool length.
      int remapUtf8To​(java.lang.String newString, int oldIndex)
      Remap a specified Utf8 entry to the given value and return its new index.
      void updateRefCount()
      Set the reference count for each element, using references from the owning ClassFile.
      • Methods inherited from class java.lang.Object

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

      • ConstantPool

        public ConstantPool​(ClassFile classFile,
                            CpInfo[] cpInfo)
        Ctor, which initializes Constant Pool using an array of CpInfo.
        Parameters:
        classFile - the class file
        cpInfo - the cp info
    • Method Detail

      • elements

        public java.util.Enumeration elements()
        Return an Enumeration of all Constant Pool entries.
        Returns:
        the enumeration
      • length

        public int length()
        Return the Constant Pool length.
        Returns:
        the int
      • getCpEntry

        public CpInfo getCpEntry​(int i)
        Return the specified Constant Pool entry.
        Parameters:
        i - the
        Returns:
        the cp entry
      • updateRefCount

        public void updateRefCount()
        Set the reference count for each element, using references from the owning ClassFile.
      • incRefCount

        public void incRefCount​(int i)
        Increment the reference count for the specified element.
        Parameters:
        i - the
      • remapUtf8To

        public int remapUtf8To​(java.lang.String newString,
                               int oldIndex)
        Remap a specified Utf8 entry to the given value and return its new index.
        Parameters:
        newString - the new string
        oldIndex - the old index
        Returns:
        the int
      • decRefCount

        public void decRefCount​(int i)
        Decrement the reference count for the specified element, blanking if Utf and refs are zero.
        Parameters:
        i - the
      • addEntry

        public int addEntry​(CpInfo entry)
        Add an entry to the constant pool and return its index.
        Parameters:
        entry - the entry
        Returns:
        the int
      • addUtf8Entry

        public int addUtf8Entry​(java.lang.String s)