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

public final Class BufWriterImpl

extends Object
implements BufWriter
Class Inheritance
All Implemented Interfaces
java.lang.classfile.BufWriter
Imports
java.lang.classfile.BufWriter, java.lang.classfile.constantpool.ClassEntry, .ConstantPool, .ConstantPoolBuilder, .PoolEntry, java.lang.runtime.ExactConversionsSupport, java.util.Arrays, jdk.internal.access.JavaLangAccess, .SharedSecrets, jdk.internal.vm.annotation.ForceInline

Field Summary

Modifier and TypeField and Description
private final ConstantPoolBuilder
private final ClassFileImpl
pack-priv byte[]
private static final JavaLangAccess
private LabelContext
private boolean
private final int
pack-priv int
private final ClassEntry

Constructor Summary

AccessConstructor and Description
public
public
BufWriterImpl(ConstantPoolBuilder constantPool, ClassFileImpl context, int initialSize)

public
BufWriterImpl(ConstantPoolBuilder constantPool, ClassFileImpl context, int initialSize, ClassEntry thisClass, int majorVersion)

Method Summary

Modifier and TypeMethod and Description
public RawBytecodeHelper.CodeRange
public boolean
canWriteDirect(ConstantPool other)

Implements java.lang.classfile.BufWriter.canWriteDirect.

Returns whether the provided constant pool is index-compatible with the constant pool of this buffer.

public ConstantPoolBuilder
constantPool()

Implements java.lang.classfile.BufWriter.constantPool.

Returns the constant pool builder associated with this buffer.

public ClassFileImpl
public void
copyTo(byte[] array, int bufferOffset)

public int
public int
public int
private void
grow(int minCapacity)

pack-priv static IllegalArgumentException
invalidIndex(int idx, PoolEntry entry)

pack-priv static byte[]
join(BufWriterImpl head, BufWriterImpl tail)

Join head and tail into an exact-size buffer

public LabelContext
public boolean
public void
patchInt(int offset, int size, int value)

Implements java.lang.classfile.BufWriter.patchInt.

Patches a previously written integer value.

public void
patchInt(int offset, int x)

public void
patchU2(int offset, int x)

public void
reserveSpace(int freeBytes)

Implements java.lang.classfile.BufWriter.reserveSpace.

Ensures that the buffer has at least freeBytes bytes of free space in the end of the buffer.

public void
setLabelContext(LabelContext labelContext, boolean labelsMatch)

public int
size()

Implements java.lang.classfile.BufWriter.size.

Returns the number of bytes that have been written to the buffer.

public int

Returns:

the index, for later patching
skip
(int
number of bytes to skip
bytes
)

Skip a few bytes in the output buffer.

public ClassEntry
public void
writeBytes(byte[] arr)

Implements java.lang.classfile.BufWriter.writeBytes.

Writes the contents of a byte array to the buffer.

public void
public void
writeBytes(byte[] arr, int start, int length)

Implements java.lang.classfile.BufWriter.writeBytes.

Writes a range of a byte array to the buffer.

public void
writeDouble(double x)

Implements java.lang.classfile.BufWriter.writeDouble.

Writes a double value, of 8 bytes, to the buffer.

public void
writeFloat(float x)

Implements java.lang.classfile.BufWriter.writeFloat.

Writes a float value, of 4 bytes, to the buffer.

public void
writeIndex(PoolEntry entry)

Implements java.lang.classfile.BufWriter.writeIndex.

Writes the index of the specified constant pool entry as a u2.

public void
writeIndex(int bytecode, PoolEntry entry)

public void
writeIndexOrZero(PoolEntry entry)

Implements java.lang.classfile.BufWriter.writeIndexOrZero.

Writes the index of the specified constant pool entry, or the value 0 if the specified entry is null, as a u2.

public void
writeInt(int x)

Implements java.lang.classfile.BufWriter.writeInt.

Writes 4 bytes, or an int, to the buffer.

public void
writeIntBytes(int intSize, long intValue)

Implements java.lang.classfile.BufWriter.writeIntBytes.

Writes a multibyte value to the buffer.

public void
writeIntInt(int x1, int x2)

public void
writeLong(long x)

Implements java.lang.classfile.BufWriter.writeLong.

Writes 8 bytes, or a long, to the buffer.

public void
writeU1(int x)

Implements java.lang.classfile.BufWriter.writeU1.

Writes a byte to the buffer.

public void
writeU1U1(int x1, int x2)

public void
writeU1U1U1(int x1, int x2, int x3)

public void
writeU1U1U2(int x1, int x2, int x3)

public void
writeU1U2(int u1, int u2)

public void
writeU1U2U2(int x1, int x2, int x3)

public void
writeU2(int x)

Implements java.lang.classfile.BufWriter.writeU2.

Writes 2 bytes, or a short, to the buffer.

public void
writeU2U1(int x1, int x2)

public void
writeU2U2(int x1, int x2)

public void
writeU2U2U2(int x1, int x2, int x3)

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

Field Detail

constantPoolback to summary
private final ConstantPoolBuilder constantPool
contextback to summary
private final ClassFileImpl context
elemsback to summary
pack-priv byte[] elems
JLAback to summary
private static final JavaLangAccess JLA
labelContextback to summary
private LabelContext labelContext
labelsMatchback to summary
private boolean labelsMatch
majorVersionback to summary
private final int majorVersion
offsetback to summary
pack-priv int offset
thisClassback to summary
private final ClassEntry thisClass

Constructor Detail

BufWriterImplback to summary
public BufWriterImpl(ConstantPoolBuilder constantPool, ClassFileImpl context)
BufWriterImplback to summary
public BufWriterImpl(ConstantPoolBuilder constantPool, ClassFileImpl context, int initialSize)
BufWriterImplback to summary
public BufWriterImpl(ConstantPoolBuilder constantPool, ClassFileImpl context, int initialSize, ClassEntry thisClass, int majorVersion)

Method Detail

bytecodeViewback to summary
public RawBytecodeHelper.CodeRange bytecodeView()
canWriteDirectback to summary
public boolean canWriteDirect(ConstantPool other)

Implements java.lang.classfile.BufWriter.canWriteDirect.

Doc from java.lang.classfile.BufWriter.canWriteDirect.

Returns whether the provided constant pool is index-compatible with the constant pool of this buffer.

This is a shortcut for constantPool().canWriteDirect(other).

Annotations
@Override
constantPoolback to summary
public ConstantPoolBuilder constantPool()

Implements java.lang.classfile.BufWriter.constantPool.

Doc from java.lang.classfile.BufWriter.constantPool.

Returns the constant pool builder associated with this buffer.

Annotations
@Override
contextback to summary
public ClassFileImpl context()
copyToback to summary
public void copyTo(byte[] array, int bufferOffset)
cpIndexback to summary
public int cpIndex(PoolEntry entry)
cpIndexOrZeroback to summary
public int cpIndexOrZero(PoolEntry entry)
getMajorVersionback to summary
public int getMajorVersion()
growback to summary
private void grow(int minCapacity)
invalidIndexback to summary
pack-priv static IllegalArgumentException invalidIndex(int idx, PoolEntry entry)
joinback to summary
pack-priv static byte[] join(BufWriterImpl head, BufWriterImpl tail)

Join head and tail into an exact-size buffer

labelContextback to summary
public LabelContext labelContext()
labelsMatchback to summary
public boolean labelsMatch(LabelContext lc)
patchIntback to summary
public void patchInt(int offset, int size, int value)

Implements java.lang.classfile.BufWriter.patchInt.

Doc from java.lang.classfile.BufWriter.patchInt.

Patches a previously written integer value. value is truncated to the given size number of bytes and written at the given offset. The end of this buffer stays unchanged.

Annotations
@Override
patchIntback to summary
public void patchInt(int offset, int x)
patchU2back to summary
public void patchU2(int offset, int x)
reserveSpaceback to summary
public void reserveSpace(int freeBytes)

Implements java.lang.classfile.BufWriter.reserveSpace.

Doc from java.lang.classfile.BufWriter.reserveSpace.

Ensures that the buffer has at least freeBytes bytes of free space in the end of the buffer.

The writing result is the same without calls to this method, but the writing process may be slower.

Annotations
@Override
setLabelContextback to summary
public void setLabelContext(LabelContext labelContext, boolean labelsMatch)
sizeback to summary
public int size()

Implements java.lang.classfile.BufWriter.size.

Doc from java.lang.classfile.BufWriter.size.

Returns the number of bytes that have been written to the buffer.

Annotations
@Override
skipback to summary
public int skip(int bytes)

Skip a few bytes in the output buffer. The skipped area has undefined value.

Parameters
bytes:int

number of bytes to skip

Returns:int

the index, for later patching

thisClassback to summary
public ClassEntry thisClass()
writeBytesback to summary
public void writeBytes(byte[] arr)

Implements java.lang.classfile.BufWriter.writeBytes.

Doc from java.lang.classfile.BufWriter.writeBytes.

Writes the contents of a byte array to the buffer.

Annotations
@Override
writeBytesback to summary
public void writeBytes(BufWriterImpl other)
writeBytesback to summary
public void writeBytes(byte[] arr, int start, int length)

Implements java.lang.classfile.BufWriter.writeBytes.

Doc from java.lang.classfile.BufWriter.writeBytes.

Writes a range of a byte array to the buffer.

Annotations
@Override
writeDoubleback to summary
public void writeDouble(double x)

Implements java.lang.classfile.BufWriter.writeDouble.

Doc from java.lang.classfile.BufWriter.writeDouble.

Writes a double value, of 8 bytes, to the buffer.

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

Annotations
@Override
writeFloatback to summary
public void writeFloat(float x)

Implements java.lang.classfile.BufWriter.writeFloat.

Doc from java.lang.classfile.BufWriter.writeFloat.

Writes a float value, of 4 bytes, to the buffer.

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

Annotations
@Override
writeIndexback to summary
public void writeIndex(PoolEntry entry)

Implements java.lang.classfile.BufWriter.writeIndex.

Doc from java.lang.classfile.BufWriter.writeIndex.

Writes the index of the specified constant pool entry as a u2. If the entry does not belong to the constant pool of this buffer, it will be converted, and the index of the converted pool entry is written instead.

Annotations
@ForceInline
@Override
writeIndexback to summary
public void writeIndex(int bytecode, PoolEntry entry)
writeIndexOrZeroback to summary
public void writeIndexOrZero(PoolEntry entry)

Implements java.lang.classfile.BufWriter.writeIndexOrZero.

Doc from java.lang.classfile.BufWriter.writeIndexOrZero.

Writes the index of the specified constant pool entry, or the value 0 if the specified entry is null, as a u2. If the entry does not belong to the constant pool of this buffer, it will be converted, and the index of the converted pool entry is written instead.

Annotations
@Override
writeIntback to summary
public void writeInt(int x)

Implements java.lang.classfile.BufWriter.writeInt.

Doc from java.lang.classfile.BufWriter.writeInt.

Writes 4 bytes, or an int, to the buffer.

Annotations
@Override
writeIntBytesback to summary
public void writeIntBytes(int intSize, long intValue)

Implements java.lang.classfile.BufWriter.writeIntBytes.

Doc from java.lang.classfile.BufWriter.writeIntBytes.

Writes a multibyte value to the buffer. intValue is truncated to the given intSize number of bytes and written.

Annotations
@Override
writeIntIntback to summary
public void writeIntInt(int x1, int x2)
writeLongback to summary
public void writeLong(long x)

Implements java.lang.classfile.BufWriter.writeLong.

Doc from java.lang.classfile.BufWriter.writeLong.

Writes 8 bytes, or a long, to the buffer.

Annotations
@Override
writeU1back to summary
public void writeU1(int x)

Implements java.lang.classfile.BufWriter.writeU1.

Doc from java.lang.classfile.BufWriter.writeU1.

Writes a byte to the buffer. x is truncated to a byte and written.

Annotations
@Override
writeU1U1back to summary
public void writeU1U1(int x1, int x2)
Annotations
@ForceInline
writeU1U1U1back to summary
public void writeU1U1U1(int x1, int x2, int x3)
writeU1U1U2back to summary
public void writeU1U1U2(int x1, int x2, int x3)
writeU1U2back to summary
public void writeU1U2(int u1, int u2)
writeU1U2U2back to summary
public void writeU1U2U2(int x1, int x2, int x3)
writeU2back to summary
public void writeU2(int x)

Implements java.lang.classfile.BufWriter.writeU2.

Doc from java.lang.classfile.BufWriter.writeU2.

Writes 2 bytes, or a short, to the buffer. x is truncated to two bytes and written.

Annotations
@ForceInline
@Override
writeU2U1back to summary
public void writeU2U1(int x1, int x2)
writeU2U2back to summary
public void writeU2U2(int x1, int x2)
writeU2U2U2back to summary
public void writeU2U2U2(int x1, int x2, int x3)
writeUtfEntryback to summary
pack-priv void writeUtfEntry(String str)
Annotations
@SuppressWarnings:deprecation