Class TemporaryConstantPool

java.lang.Object
org.glavo.classfile.impl.TemporaryConstantPool
All Implemented Interfaces:
Iterable<PoolEntry>, ClassFileElement, ConstantPool, ConstantPoolBuilder, WritableElement<ConstantPool>

public final class TemporaryConstantPool extends Object implements ConstantPoolBuilder
  • Field Details

  • Method Details

    • utf8Entry

      public Utf8Entry utf8Entry(String s)
      Description copied from interface: ConstantPoolBuilder
      Returns A Utf8Entry describing the provided String. If a UTF8 entry in the pool already describes this string, it is returned; otherwise, a new entry is added and the new entry is returned.
      Specified by:
      utf8Entry in interface ConstantPoolBuilder
      Parameters:
      s - the string
      Returns:
      A Utf8Entry describing the provided String
    • intEntry

      public IntegerEntry intEntry(int value)
      Description copied from interface: ConstantPoolBuilder
      Returns An IntegerEntry describing the provided value. If an integer entry in the pool already describes this value, it is returned; otherwise, a new entry is added and the new entry is returned.
      Specified by:
      intEntry in interface ConstantPoolBuilder
      Parameters:
      value - the value
      Returns:
      An IntegerEntry describing the provided value
    • floatEntry

      public FloatEntry floatEntry(float value)
      Description copied from interface: ConstantPoolBuilder
      Returns A FloatEntry describing the provided value. If a float entry in the pool already describes this value, it is returned; otherwise, a new entry is added and the new entry is returned.
      Specified by:
      floatEntry in interface ConstantPoolBuilder
      Parameters:
      value - the value
      Returns:
      A FloatEntry describing the provided value
    • longEntry

      public LongEntry longEntry(long value)
      Description copied from interface: ConstantPoolBuilder
      Returns A LongEntry describing the provided value. If a long entry in the pool already describes this value, it is returned; otherwise, a new entry is added and the new entry is returned.
      Specified by:
      longEntry in interface ConstantPoolBuilder
      Parameters:
      value - the value
      Returns:
      A LongEntry describing the provided value
    • doubleEntry

      public DoubleEntry doubleEntry(double value)
      Description copied from interface: ConstantPoolBuilder
      Returns A DoubleEntry describing the provided value. If a double entry in the pool already describes this value, it is returned; otherwise, a new entry is added and the new entry is returned.
      Specified by:
      doubleEntry in interface ConstantPoolBuilder
      Parameters:
      value - the value
      Returns:
      A DoubleEntry describing the provided value
    • classEntry

      public ClassEntry classEntry(Utf8Entry name)
      Description copied from interface: ConstantPoolBuilder
      Returns A ClassEntry describing the class whose internal name is encoded in the provided Utf8Entry. If a Class entry in the pool already describes this class, it is returned; otherwise, a new entry is added and the new entry is returned.
      Specified by:
      classEntry in interface ConstantPoolBuilder
      Parameters:
      name - the constant pool entry describing the internal name of the class
      Returns:
      A ClassEntry describing the class whose internal name is encoded in the provided Utf8Entry
    • packageEntry

      public PackageEntry packageEntry(Utf8Entry name)
      Description copied from interface: ConstantPoolBuilder
      Returns A PackageEntry describing the class whose internal name is encoded in the provided Utf8Entry. If a Package entry in the pool already describes this class, it is returned; otherwise, a new entry is added and the new entry is returned.
      Specified by:
      packageEntry in interface ConstantPoolBuilder
      Parameters:
      name - the constant pool entry describing the internal name of the package
      Returns:
      A PackageEntry describing the class whose internal name is encoded in the provided Utf8Entry
    • moduleEntry

      public ModuleEntry moduleEntry(Utf8Entry name)
      Description copied from interface: ConstantPoolBuilder
      Returns A ModuleEntry describing the module whose name is encoded in the provided Utf8Entry. If a module entry in the pool already describes this class, it is returned; otherwise, a new entry is added and the new entry is returned.
      Specified by:
      moduleEntry in interface ConstantPoolBuilder
      Parameters:
      name - the constant pool entry describing the module name
      Returns:
      A ModuleEntry describing the module whose name is encoded in the provided Utf8Entry
    • nameAndTypeEntry

      public NameAndTypeEntry nameAndTypeEntry(Utf8Entry nameEntry, Utf8Entry typeEntry)
      Description copied from interface: ConstantPoolBuilder
      Returns A NameAndTypeEntry describing the provided name and type. If a NameAndType entry in the pool already describes this name and type, it is returned; otherwise, a new entry is added and the new entry is returned.
      Specified by:
      nameAndTypeEntry in interface ConstantPoolBuilder
      Parameters:
      nameEntry - the member name
      typeEntry - the member field or method descriptor
      Returns:
      A NameAndTypeEntry describing the provided name and type
    • fieldRefEntry

      public FieldRefEntry fieldRefEntry(ClassEntry owner, NameAndTypeEntry nameAndType)
      Description copied from interface: ConstantPoolBuilder
      Returns A FieldRefEntry describing a field of a class. If a FieldRef entry in the pool already describes this field, it is returned; otherwise, a new entry is added and the new entry is returned.
      Specified by:
      fieldRefEntry in interface ConstantPoolBuilder
      Parameters:
      owner - the class the field is a member of
      nameAndType - the name and type of the field
      Returns:
      A FieldRefEntry describing a field of a class
    • methodRefEntry

      public MethodRefEntry methodRefEntry(ClassEntry owner, NameAndTypeEntry nameAndType)
      Description copied from interface: ConstantPoolBuilder
      Returns A MethodRefEntry describing a method of a class. If a MethodRefEntry entry in the pool already describes this method, it is returned; otherwise, a new entry is added and the new entry is returned.
      Specified by:
      methodRefEntry in interface ConstantPoolBuilder
      Parameters:
      owner - the class the method is a member of
      nameAndType - the name and type of the method
      Returns:
      A MethodRefEntry describing a method of a class
    • interfaceMethodRefEntry

      public InterfaceMethodRefEntry interfaceMethodRefEntry(ClassEntry owner, NameAndTypeEntry nameAndType)
      Description copied from interface: ConstantPoolBuilder
      Returns A InterfaceMethodRefEntry describing a method of a class. If a InterfaceMethodRefEntry entry in the pool already describes this method, it is returned; otherwise, a new entry is added and the new entry is returned.
      Specified by:
      interfaceMethodRefEntry in interface ConstantPoolBuilder
      Parameters:
      owner - the class the method is a member of
      nameAndType - the name and type of the method
      Returns:
      A InterfaceMethodRefEntry describing a method of a class
    • methodTypeEntry

      public MethodTypeEntry methodTypeEntry(MethodTypeDesc descriptor)
      Description copied from interface: ConstantPoolBuilder
      Returns A MethodTypeEntry describing a method type. If a MethodType entry in the pool already describes this method type, it is returned; otherwise, a new entry is added and the new entry is returned.
      Specified by:
      methodTypeEntry in interface ConstantPoolBuilder
      Parameters:
      descriptor - the symbolic descriptor of the method type
      Returns:
      A MethodTypeEntry describing a method type
    • methodTypeEntry

      public MethodTypeEntry methodTypeEntry(Utf8Entry descriptor)
      Description copied from interface: ConstantPoolBuilder
      Returns A MethodTypeEntry describing a method type. If a MethodType entry in the pool already describes this method type, it is returned; otherwise, a new entry is added and the new entry is returned.
      Specified by:
      methodTypeEntry in interface ConstantPoolBuilder
      Parameters:
      descriptor - the constant pool entry for the method type descriptor
      Returns:
      A MethodTypeEntry describing a method type
    • methodHandleEntry

      public MethodHandleEntry methodHandleEntry(int refKind, MemberRefEntry reference)
      Description copied from interface: ConstantPoolBuilder
      Returns A MethodHandleEntry describing a field accessor or method. If a MethodHandle entry in the pool already describes this method handle, it is returned; otherwise, a new entry is added and the new entry is returned.
      Specified by:
      methodHandleEntry in interface ConstantPoolBuilder
      Parameters:
      refKind - the reference kind of the method handle
      reference - the constant pool entry describing the field or method
      Returns:
      A MethodHandleEntry describing a field accessor or method
    • invokeDynamicEntry

      public InvokeDynamicEntry invokeDynamicEntry(BootstrapMethodEntry bootstrapMethodEntry, NameAndTypeEntry nameAndType)
      Description copied from interface: ConstantPoolBuilder
      Returns An InvokeDynamicEntry describing a dynamic call site. If an InvokeDynamic entry in the pool already describes this site, it is returned; otherwise, a new entry is added and the new entry is returned.
      Specified by:
      invokeDynamicEntry in interface ConstantPoolBuilder
      Parameters:
      bootstrapMethodEntry - the entry in the bootstrap method table
      nameAndType - the invocation name and type
      Returns:
      An InvokeDynamicEntry describing a dynamic call site
    • constantDynamicEntry

      public ConstantDynamicEntry constantDynamicEntry(BootstrapMethodEntry bootstrapMethodEntry, NameAndTypeEntry nameAndType)
      Description copied from interface: ConstantPoolBuilder
      Returns A ConstantDynamicEntry describing a dynamic constant. If a ConstantDynamic entry in the pool already describes this site, it is returned; otherwise, a new entry is added and the new entry is returned.
      Specified by:
      constantDynamicEntry in interface ConstantPoolBuilder
      Parameters:
      bootstrapMethodEntry - the entry in the bootstrap method table
      nameAndType - the invocation name and type
      Returns:
      A ConstantDynamicEntry describing a dynamic constant
    • stringEntry

      public StringEntry stringEntry(Utf8Entry utf8)
      Description copied from interface: ConstantPoolBuilder
      Returns A StringEntry referencing the provided UTF8 entry. If a String entry in the pool already describes this value, it is returned; otherwise, a new entry is added and the new entry is returned.
      Specified by:
      stringEntry in interface ConstantPoolBuilder
      Parameters:
      utf8 - the UTF8 entry describing the string
      Returns:
      A StringEntry referencing the provided UTF8 entry
    • bsmEntry

      public BootstrapMethodEntry bsmEntry(MethodHandleEntry methodReference, List<LoadableConstantEntry> arguments)
      Description copied from interface: ConstantPoolBuilder
      Returns a BootstrapMethodEntry describing the provided bootstrap method and static arguments.
      Specified by:
      bsmEntry in interface ConstantPoolBuilder
      Parameters:
      methodReference - the bootstrap method
      arguments - the bootstrap arguments
      Returns:
      a BootstrapMethodEntry describing the provided bootstrap method and static arguments
    • entryByIndex

      public PoolEntry entryByIndex(int index)
      Description copied from interface: ConstantPool
      Returns the entry at the specified index.
      Specified by:
      entryByIndex in interface ConstantPool
      Parameters:
      index - the index within the pool of the desired entry
      Returns:
      the entry at the specified index
    • size

      public int size()
      Description copied from interface: ConstantPool
      Returns the size of the constant pool.
      Specified by:
      size in interface ConstantPool
      Returns:
      the size of the constant pool
    • bootstrapMethodEntry

      public BootstrapMethodEntry bootstrapMethodEntry(int index)
      Description copied from interface: ConstantPool
      Returns the BootstrapMethodEntry at the specified index within the bootstrap method table.
      Specified by:
      bootstrapMethodEntry in interface ConstantPool
      Parameters:
      index - the index within the bootstrap method table of the desired entry
      Returns:
      the BootstrapMethodEntry at the specified index within the bootstrap method table
    • bootstrapMethodCount

      public int bootstrapMethodCount()
      Description copied from interface: ConstantPool
      Returns the number of entries in the bootstrap method table.
      Specified by:
      bootstrapMethodCount in interface ConstantPool
      Returns:
      the number of entries in the bootstrap method table
    • canWriteDirect

      public boolean canWriteDirect(ConstantPool constantPool)
      Description copied from interface: ConstantPoolBuilder
      Returns whether the provided constant pool is index-compatible with this one. This may be because they are the same constant pool, or because this constant pool was copied from the other.
      Specified by:
      canWriteDirect in interface ConstantPoolBuilder
      Parameters:
      constantPool - the other constant pool
      Returns:
      whether the provided constant pool is index-compatible with this one
    • writeBootstrapMethods

      public boolean writeBootstrapMethods(BufWriter buf)
      Description copied from interface: ConstantPoolBuilder
      Writes associated bootstrap method entries to the specified writer
      Specified by:
      writeBootstrapMethods in interface ConstantPoolBuilder
      Parameters:
      buf - the writer
      Returns:
      false when no bootstrap method entry has been written
    • writeTo

      public void writeTo(BufWriter buf)
      Description copied from interface: WritableElement
      Writes the element to the specified writer
      Specified by:
      writeTo in interface WritableElement<ConstantPool>
      Parameters:
      buf - the writer