APIdia Launch Partner
Top Fields Constructors Methods
jdk.internal.classfile.impl

public final Class ClassReaderImpl

extends Object
implements ClassReader
Class Inheritance
All Implemented Interfaces
java.lang.classfile.ClassReader, java.lang.classfile.constantpool.ConstantPool, java.lang.Iterable
Imports
java.lang.classfile.*, java.lang.classfile.attribute.BootstrapMethodsAttribute, java.lang.classfile.constantpool.ClassEntry, .ConstantPoolException, .LoadableConstantEntry, .PoolEntry, .Utf8Entry, java.util.ArrayList, .Arrays, .List, .Objects, .Optional, java.util.function.Function

Field Summary

Modifier and TypeField and Description
private final Function<Utf8Entry, AttributeMapper<?>>
private BootstrapMethodsAttribute
private List<BootstrapMethodEntryImpl>
private final byte[]
private final int
private final int
private ClassModel
pack-priv final ClassFileImpl
pack-priv final PoolEntry[]
pack-priv static final int
private final int[]
private final int
pack-priv final int
private final int
private Optional<ClassEntry>
private ClassEntry
private final int

Constructor Summary

AccessConstructor and Description
pack-priv
ClassReaderImpl(byte[] classfileBytes, ClassFileImpl context)

Method Summary

Modifier and TypeMethod and Description
public int
bootstrapMethodCount()

Implements java.lang.classfile.constantpool.ConstantPool.bootstrapMethodCount.

Returns the number of entries in the bootstrap method table.

public BootstrapMethodEntryImpl
bootstrapMethodEntry(int index)

Implements java.lang.classfile.constantpool.ConstantPool.bootstrapMethodEntry.

Returns the BootstrapMethodEntry at the specified index within the bootstrap method table.

pack-priv BootstrapMethodsAttribute
pack-priv List<BootstrapMethodEntryImpl>
private static boolean
checkTag(int tag, Class<?> cls)

pack-priv static <T extends PoolEntry> T
checkType(PoolEntry e, int index, Class<T> cls)

private static ConstantPoolException
checkTypeError(int index, Class<?> cls)

public int
classfileLength()

Implements java.lang.classfile.ClassReader.classfileLength.

Returns the length of the class file, in number of bytes.

public boolean
compare(BufWriterImpl bufWriter, int bufWriterOffset, int classReaderOffset, int length)

public ClassFileImpl
public void
copyBytesTo(BufWriter buf, int p, int len)

Implements java.lang.classfile.ClassReader.copyBytesTo.

Copy a range of bytes from the class file to a BufWriter.

public Function<Utf8Entry, AttributeMapper<?>>
customAttributes()

Implements java.lang.classfile.ClassReader.customAttributes.

Returns the table of custom attribute mappers.

public PoolEntry
entryByIndex(int index)

Implements java.lang.classfile.constantpool.ConstantPool.entryByIndex.

Returns the entry at the specified index.

public <T extends PoolEntry> T
entryByIndex(int index, Class<T> cls)

Implements java.lang.classfile.constantpool.ConstantPool.entryByIndex.

Returns the entry of a given type at the specified index.

public int
flags()

Implements java.lang.classfile.ClassReader.flags.

Returns the access flags for the class, as a bit mask.

pack-priv ClassModel
private static IllegalArgumentException
public byte[]
readBytes(int p, int len)

Implements java.lang.classfile.ClassReader.readBytes.

Returns a copy of the bytes at the specified range in the class file.

public double
readDouble(int p)

Implements java.lang.classfile.ClassReader.readDouble.

Returns the double value at the specified offset within the class file.

public PoolEntry
readEntry(int pos)

Implements java.lang.classfile.ClassReader.readEntry.

Returns the constant pool entry whose index is given at the specified offset within the class file.

public <T extends PoolEntry> T
readEntry(int pos, Class<T> cls)

Implements java.lang.classfile.ClassReader.readEntry.

Returns the constant pool entry of a given type whose index is given at the specified offset within the class file.

public PoolEntry
readEntryOrNull(int pos)

Implements java.lang.classfile.ClassReader.readEntryOrNull.

Returns the constant pool entry whose index is given at the specified offset within the class file, or null if the index at the specified offset is zero.

public <T extends PoolEntry> T
readEntryOrNull(int offset, Class<T> cls)

Implements java.lang.classfile.ClassReader.readEntryOrNull.

Returns the constant pool entry of a given type whose index is given at the specified offset within the class file, or null if the index at the specified offset is zero.

public float
readFloat(int p)

Implements java.lang.classfile.ClassReader.readFloat.

Returns the float value at the specified offset within the class file.

public int
readInt(int p)

Implements java.lang.classfile.ClassReader.readInt.

Returns the signed int at the specified offset within the class file.

public long
readLong(int p)

Implements java.lang.classfile.ClassReader.readLong.

Returns the signed long at the specified offset within the class file.

public int
readS1(int p)

Implements java.lang.classfile.ClassReader.readS1.

Returns the signed byte at the specified offset within the class file.

public int
readS2(int p)

Implements java.lang.classfile.ClassReader.readS2.

Returns the signed byte at the specified offset within the class file.

public int
readU1(int p)

Implements java.lang.classfile.ClassReader.readU1.

Returns the unsigned byte at the specified offset within the class file.

public int
readU2(int p)

Implements java.lang.classfile.ClassReader.readU2.

Returns the u2 at the specified offset within the class file.

pack-priv void
setContainedClass(ClassModel containedClass)

public int
size()

Implements java.lang.classfile.constantpool.ConstantPool.size.

Returns the exclusive upper bound of the valid indices of this constant pool.

public int
skipAttributeHolder(int offset)

public Optional<ClassEntry>
superclassEntry()

Implements java.lang.classfile.ClassReader.superclassEntry.

Returns the constant pool entry describing the name of the superclass, if any.

public ClassEntry
thisClassEntry()

Implements java.lang.classfile.ClassReader.thisClassEntry.

Returns the constant pool entry describing the name of class.

public int
pack-priv boolean
pack-priv void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

attributeMapperback to summary
private final Function<Utf8Entry, AttributeMapper<?>> attributeMapper
bootstrapMethodsAttributeback to summary
private BootstrapMethodsAttribute bootstrapMethodsAttribute
bsmEntriesback to summary
private List<BootstrapMethodEntryImpl> bsmEntries
bufferback to summary
private final byte[] buffer
classfileLengthback to summary
private final int classfileLength
constantPoolCountback to summary
private final int constantPoolCount
containedClassback to summary
private ClassModel containedClass
contextback to summary
pack-priv final ClassFileImpl context
cpback to summary
pack-priv final PoolEntry[] cp
CP_ITEM_STARTback to summary
pack-priv static final int CP_ITEM_START
cpOffsetback to summary
private final int[] cpOffset
flagsback to summary
private final int flags
interfacesPosback to summary
pack-priv final int interfacesPos
metadataStartback to summary
private final int metadataStart
superclassback to summary
private Optional<ClassEntry> superclass
thisClassback to summary
private ClassEntry thisClass
thisClassPosback to summary
private final int thisClassPos

Constructor Detail

ClassReaderImplback to summary
pack-priv ClassReaderImpl(byte[] classfileBytes, ClassFileImpl context)

Method Detail

bootstrapMethodCountback to summary
public int bootstrapMethodCount()

Implements java.lang.classfile.constantpool.ConstantPool.bootstrapMethodCount.

Doc from java.lang.classfile.constantpool.ConstantPool.bootstrapMethodCount.

Returns the number of entries in the bootstrap method table.

Annotations
@Override
bootstrapMethodEntryback to summary
public BootstrapMethodEntryImpl bootstrapMethodEntry(int index)

Implements java.lang.classfile.constantpool.ConstantPool.bootstrapMethodEntry.

Doc from java.lang.classfile.constantpool.ConstantPool.bootstrapMethodEntry.

Returns the BootstrapMethodEntry at the specified index within the bootstrap method table.

Annotations
@Override
bootstrapMethodsAttributeback to summary
pack-priv BootstrapMethodsAttribute bootstrapMethodsAttribute()
bsmEntriesback to summary
pack-priv List<BootstrapMethodEntryImpl> bsmEntries()
checkTagback to summary
private static boolean checkTag(int tag, Class<?> cls)
checkTypeback to summary
pack-priv static <T extends PoolEntry> T checkType(PoolEntry e, int index, Class<T> cls)
checkTypeErrorback to summary
private static ConstantPoolException checkTypeError(int index, Class<?> cls)
classfileLengthback to summary
public int classfileLength()

Implements java.lang.classfile.ClassReader.classfileLength.

Doc from java.lang.classfile.ClassReader.classfileLength.

Returns the length of the class file, in number of bytes.

Annotations
@Override
compareback to summary
public boolean compare(BufWriterImpl bufWriter, int bufWriterOffset, int classReaderOffset, int length)
contextback to summary
public ClassFileImpl context()
copyBytesToback to summary
public void copyBytesTo(BufWriter buf, int p, int len)

Implements java.lang.classfile.ClassReader.copyBytesTo.

Doc from java.lang.classfile.ClassReader.copyBytesTo.

Copy a range of bytes from the class file to a BufWriter.

Annotations
@Override
customAttributesback to summary
public Function<Utf8Entry, AttributeMapper<?>> customAttributes()

Implements java.lang.classfile.ClassReader.customAttributes.

Doc from java.lang.classfile.ClassReader.customAttributes.

Returns the table of custom attribute mappers. This is derived from the processing option ClassFile.AttributeMapperOption.

Annotations
@Override
entryByIndexback to summary
public PoolEntry entryByIndex(int index)

Implements java.lang.classfile.constantpool.ConstantPool.entryByIndex.

Doc from java.lang.classfile.constantpool.ConstantPool.entryByIndex.

Returns the entry at the specified index.

Annotations
@Override
entryByIndexback to summary
public <T extends PoolEntry> T entryByIndex(int index, Class<T> cls)

Implements java.lang.classfile.constantpool.ConstantPool.entryByIndex.

Doc from java.lang.classfile.constantpool.ConstantPool.entryByIndex.

Returns the entry of a given type at the specified index.

Annotations
@Override
flagsback to summary
public int flags()

Implements java.lang.classfile.ClassReader.flags.

Doc from java.lang.classfile.ClassReader.flags.

Returns the access flags for the class, as a bit mask.

Annotations
@Override
getContainedClassback to summary
pack-priv ClassModel getContainedClass()
outOfBoundsErrorback to summary
private static IllegalArgumentException outOfBoundsError(IndexOutOfBoundsException cause)
readBytesback to summary
public byte[] readBytes(int p, int len)

Implements java.lang.classfile.ClassReader.readBytes.

Doc from java.lang.classfile.ClassReader.readBytes.

Returns a copy of the bytes at the specified range in the class file.

Annotations
@Override
readDoubleback to summary
public double readDouble(int p)

Implements java.lang.classfile.ClassReader.readDouble.

Doc from java.lang.classfile.ClassReader.readDouble.

Returns the double value at the specified offset within the class file. Reads 8 bytes of value.

In the conversions, all NaN values of the double may or may not be collapsed into a single "canonical" NaN value.

Annotations
@Override
readEntryback to summary
public PoolEntry readEntry(int pos)

Implements java.lang.classfile.ClassReader.readEntry.

Doc from java.lang.classfile.ClassReader.readEntry.

Returns the constant pool entry whose index is given at the specified offset within the class file.

Annotations
@Override
readEntryback to summary
public <T extends PoolEntry> T readEntry(int pos, Class<T> cls)

Implements java.lang.classfile.ClassReader.readEntry.

Doc from java.lang.classfile.ClassReader.readEntry.

Returns the constant pool entry of a given type whose index is given at the specified offset within the class file.

Annotations
@Override
readEntryOrNullback to summary
public PoolEntry readEntryOrNull(int pos)

Implements java.lang.classfile.ClassReader.readEntryOrNull.

Doc from java.lang.classfile.ClassReader.readEntryOrNull.

Returns the constant pool entry whose index is given at the specified offset within the class file, or null if the index at the specified offset is zero.

Annotations
@Override
readEntryOrNullback to summary
public <T extends PoolEntry> T readEntryOrNull(int offset, Class<T> cls)

Implements java.lang.classfile.ClassReader.readEntryOrNull.

Doc from java.lang.classfile.ClassReader.readEntryOrNull.

Returns the constant pool entry of a given type whose index is given at the specified offset within the class file, or null if the index at the specified offset is zero.

Annotations
@Override
readFloatback to summary
public float readFloat(int p)

Implements java.lang.classfile.ClassReader.readFloat.

Doc from java.lang.classfile.ClassReader.readFloat.

Returns the float value at the specified offset within the class file. Reads 4 bytes of value.

In the conversions, all NaN values of the float may or may not be collapsed into a single "canonical" NaN value.

Annotations
@Override
readIntback to summary
public int readInt(int p)

Implements java.lang.classfile.ClassReader.readInt.

Doc from java.lang.classfile.ClassReader.readInt.

Returns the signed int at the specified offset within the class file. Reads 4 bytes of value.

Annotations
@Override
readLongback to summary
public long readLong(int p)

Implements java.lang.classfile.ClassReader.readLong.

Doc from java.lang.classfile.ClassReader.readLong.

Returns the signed long at the specified offset within the class file. Reads 8 bytes of value.

Annotations
@Override
readS1back to summary
public int readS1(int p)

Implements java.lang.classfile.ClassReader.readS1.

Doc from java.lang.classfile.ClassReader.readS1.

Returns the signed byte at the specified offset within the class file. Reads a byte and sign-extends it to an int.

Annotations
@Override
readS2back to summary
public int readS2(int p)

Implements java.lang.classfile.ClassReader.readS2.

Doc from java.lang.classfile.ClassReader.readS2.

Returns the signed byte at the specified offset within the class file. Reads a 2-byte value and sign-extends it to an int.

Annotations
@Override
readU1back to summary
public int readU1(int p)

Implements java.lang.classfile.ClassReader.readU1.

Doc from java.lang.classfile.ClassReader.readU1.

Returns the unsigned byte at the specified offset within the class file. Reads a byte and zero-extends it to an int.

Annotations
@Override
readU2back to summary
public int readU2(int p)

Implements java.lang.classfile.ClassReader.readU2.

Doc from java.lang.classfile.ClassReader.readU2.

Returns the u2 at the specified offset within the class file. Reads a 2-byte value and zero-extends it to an int.

Annotations
@Override
setContainedClassback to summary
pack-priv void setContainedClass(ClassModel containedClass)
sizeback to summary
public int size()

Implements java.lang.classfile.constantpool.ConstantPool.size.

Doc from java.lang.classfile.constantpool.ConstantPool.size.

Returns the exclusive upper bound of the valid indices of this constant pool. The actual number of entries is lower because 0, size() are not valid, and a valid index may be unusable.

Annotations
@Override
skipAttributeHolderback to summary
public int skipAttributeHolder(int offset)
superclassEntryback to summary
public Optional<ClassEntry> superclassEntry()

Implements java.lang.classfile.ClassReader.superclassEntry.

Doc from java.lang.classfile.ClassReader.superclassEntry.

Returns the constant pool entry describing the name of the superclass, if any.

Annotations
@Override
thisClassEntryback to summary
public ClassEntry thisClassEntry()

Implements java.lang.classfile.ClassReader.thisClassEntry.

Doc from java.lang.classfile.ClassReader.thisClassEntry.

Returns the constant pool entry describing the name of class.

Annotations
@Override
thisClassPosback to summary
public int thisClassPos()
writeBootstrapMethodsback to summary
pack-priv boolean writeBootstrapMethods(BufWriterImpl buf)
writeConstantPoolEntriesback to summary
pack-priv void writeConstantPoolEntries(BufWriter buf)