Top Description Methods
java.lang.classfile

public sealed Interface ClassFileBuilder<E extends ClassFileElement, B extends ClassFileBuilder<E, B>>

extends Consumer<E extends ClassFileElement>
Known Direct Subinterfaces
java.lang.classfile.CodeBuilder, java.lang.classfile.FieldBuilder, java.lang.classfile.MethodBuilder, java.lang.classfile.ClassBuilder
Annotations
@PreviewFeature
feature:CLASSFILE_API
Type Parameters
<E>
the element type
<B>
the builder type
Imports
java.lang.constant.ClassDesc, java.util.function.Consumer, java.lang.classfile.constantpool.ConstantPool, .ConstantPoolBuilder, jdk.internal.javac.PreviewFeature

Preview

Second Preview of ClassFile API (JEP 466).

Programs can only use ClassFileBuilder when preview features are enabled.
Preview features may be removed in a future release, or upgraded to permanent features of the Java platform.

A builder for a classfile or portion of a classfile. Builders are rarely created directly; they are passed to handlers by methods such as ClassFile#build(ClassDesc, Consumer) or to transforms. Elements of the newly built entity can be specified abstractly (by passing a ClassFileElement to with(ClassFileElement) or concretely by calling the various withXxx methods.
Since
22
See Also
ClassFileTransform

Method Summary

Modifier and TypeMethod and Description
public default void
accept(E
the element
e
)

Implements java.util.function.Consumer.accept.

Integrate the ClassFileElement into the entity being built.

public default boolean

Returns:

whether the provided constant pool is compatible with this builder
canWriteDirect
(ConstantPool
the constant pool to test compatibility with
source
)

Returns whether the provided constant pool is compatible with this builder.

public ConstantPoolBuilder

Returns:

the constant pool builder associated with this builder
constantPool
()

Returns the constant pool builder associated with this builder.

public default void
transform(CompoundElement<E>
the model to transform
model
,
ClassFileTransform<?, E, B>
the transform to apply
transform
)

Apply a transform to a model, directing results to this builder.

public B

Returns:

this builder
with
(E
the element
e
)

Integrate the ClassFileElement into the entity being built.

Inherited from java.util.function.Consumer:
andThen

Method Detail

acceptback to summary
public default void accept(E e)

Implements java.util.function.Consumer.accept.

Integrate the ClassFileElement into the entity being built.

Parameters
e:E

the element

Annotations
@Override
canWriteDirectback to summary
public default boolean canWriteDirect(ConstantPool source)

Returns whether the provided constant pool is compatible with this builder.

Parameters
source:ConstantPool

the constant pool to test compatibility with

Returns:boolean

whether the provided constant pool is compatible with this builder

constantPoolback to summary
public ConstantPoolBuilder constantPool()

Returns the constant pool builder associated with this builder.

Returns:ConstantPoolBuilder

the constant pool builder associated with this builder

transformback to summary
public default void transform(CompoundElement<E> model, ClassFileTransform<?, E, B> transform)

Apply a transform to a model, directing results to this builder.

Parameters
model:CompoundElement<E>

the model to transform

transform:ClassFileTransform<?, E, B>

the transform to apply

withback to summary
public B with(E e)

Integrate the ClassFileElement into the entity being built.

Parameters
e:E

the element

Returns:B

this builder