Top Description Inners Methods
net.bytebuddy.dynamic.scaffold

public Interface ClassWriterStrategy

Known Direct Implementers
net.bytebuddy.dynamic.scaffold.ClassWriterStrategy.Default
Imports
net.bytebuddy.description.type.TypeDescription, net.bytebuddy.pool.TypePool, net.bytebuddy.jar.asm.ClassReader, .ClassWriter

A class writer strategy is responsible for the creation of a ClassWriter when creating a type.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
ClassWriterStrategy.Default

Default implementations of class writer strategies.

public static class
ClassWriterStrategy.FrameComputingClassWriter

A class writer that piggy-backs on Byte Buddy's TypePool to avoid class loading or look-up errors when redefining a class.

Method Summary

Modifier and TypeMethod and Description
public ClassWriter

Returns:

The class writer to use.
resolve
(int
The flags to set.
flags
,
TypePool
A type pool for locating types.
typePool
)

Resolves a class writer.

public ClassWriter

Returns:

The class writer to use.
resolve
(int
The flags to set.
flags
,
TypePool
A type pool for locating types.
typePool
,
ClassReader
The class reader from which the original class is read.
classReader
)

Resolves a class writer.

Method Detail

resolveback to summary
public ClassWriter resolve(int flags, TypePool typePool)

Resolves a class writer.

Parameters
flags:int

The flags to set.

typePool:TypePool

A type pool for locating types.

Returns:ClassWriter

The class writer to use.

resolveback to summary
public ClassWriter resolve(int flags, TypePool typePool, ClassReader classReader)

Resolves a class writer.

Parameters
flags:int

The flags to set.

typePool:TypePool

A type pool for locating types.

classReader:ClassReader

The class reader from which the original class is read.

Returns:ClassWriter

The class writer to use.

net.bytebuddy.dynamic.scaffold back to summary

public sealed Enum ClassWriterStrategy.Default

extends Enum<ClassWriterStrategy.Default>
implements ClassWriterStrategy
Class Inheritance
All Implemented Interfaces
net.bytebuddy.dynamic.scaffold.ClassWriterStrategy

Default implementations of class writer strategies.

Field Summary

Modifier and TypeField and Description
public static final ClassWriterStrategy.Default
CONSTANT_POOL_DISCARDING

A class writer strategy that discards the original class's constant pool if applicable.

public static final ClassWriterStrategy.Default
CONSTANT_POOL_RETAINING

A class writer strategy that retains the original class's constant pool if applicable.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public ClassWriter
resolve(int
The flags to set.
flags
,
TypePool
A type pool for locating types.
typePool
)

Implements net.bytebuddy.dynamic.scaffold.ClassWriterStrategy.resolve.

Resolves a class writer.
public static ClassWriterStrategy.Default
public static ClassWriterStrategy.Default[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

CONSTANT_POOL_DISCARDINGback to summary
public static final ClassWriterStrategy.Default CONSTANT_POOL_DISCARDING

A class writer strategy that discards the original class's constant pool if applicable.

CONSTANT_POOL_RETAININGback to summary
public static final ClassWriterStrategy.Default CONSTANT_POOL_RETAINING

A class writer strategy that retains the original class's constant pool if applicable.

Constructor Detail

Defaultback to summary
private Default()

Method Detail

resolveback to summary
public ClassWriter resolve(int flags, TypePool typePool)

Implements net.bytebuddy.dynamic.scaffold.ClassWriterStrategy.resolve.

Doc from net.bytebuddy.dynamic.scaffold.ClassWriterStrategy.resolve.

Resolves a class writer.

Parameters
flags:int

The flags to set.

typePool:TypePool

A type pool for locating types.

Returns:ClassWriter

The class writer to use.

valueOfback to summary
public static ClassWriterStrategy.Default valueOf(String name)
valuesback to summary
public static ClassWriterStrategy.Default[] values()
net.bytebuddy.dynamic.scaffold back to summary

public Class ClassWriterStrategy.FrameComputingClassWriter

extends ClassWriter
Class Inheritance

A class writer that piggy-backs on Byte Buddy's TypePool to avoid class loading or look-up errors when redefining a class. This is not available when creating a new class where automatic frame computation is however not normally a requirement.

Field Summary

Modifier and TypeField and Description
private final TypePool
typePool

The type pool to use for computing stack map frames, if required.

Inherited from net.bytebuddy.jar.asm.ClassWriter:
COMPUTE_FRAMESCOMPUTE_MAXS

Constructor Summary

AccessConstructor and Description
public
FrameComputingClassWriter(int
The flags to be handed to the writer.
flags
,
TypePool
The type pool to use for computing stack map frames, if required.
typePool
)

Creates a new frame computing class writer.

public
FrameComputingClassWriter(ClassReader
The class reader from which the original class is read.
classReader
,
int
The flags to be handed to the writer.
flags
,
TypePool
The type pool to use for computing stack map frames, if required.
typePool
)

Creates a new frame computing class writer.

Method Summary

Modifier and TypeMethod and Description
protected String
getCommonSuperClass(String
the internal name of a class (see Type#getInternalName()).
leftTypeName
,
String
the internal name of another class (see Type#getInternalName()).
rightTypeName
)

Overrides net.bytebuddy.jar.asm.ClassWriter.getCommonSuperClass.

Returns the common super type of the two given types.
Inherited from net.bytebuddy.jar.asm.ClassWriter:
getClassLoaderhasFlagsnewClassnewConstnewConstantDynamicnewFieldnewHandlenewHandlenewInvokeDynamicnewMethodnewMethodTypenewModulenewNameTypenewPackagenewUTF8toByteArrayvisitvisitAnnotationvisitAttributevisitEndvisitFieldvisitInnerClassvisitMethodvisitModulevisitNestHostvisitNestMembervisitOuterClassvisitPermittedSubclassvisitRecordComponentvisitSourcevisitTypeAnnotation

Field Detail

typePoolback to summary
private final TypePool typePool

The type pool to use for computing stack map frames, if required.

Constructor Detail

FrameComputingClassWriterback to summary
public FrameComputingClassWriter(int flags, TypePool typePool)

Creates a new frame computing class writer.

Parameters
flags:int

The flags to be handed to the writer.

typePool:TypePool

The type pool to use for computing stack map frames, if required.

FrameComputingClassWriterback to summary
public FrameComputingClassWriter(ClassReader classReader, int flags, TypePool typePool)

Creates a new frame computing class writer.

Parameters
classReader:ClassReader

The class reader from which the original class is read.

flags:int

The flags to be handed to the writer.

typePool:TypePool

The type pool to use for computing stack map frames, if required.

Method Detail

getCommonSuperClassback to summary
protected String getCommonSuperClass(String leftTypeName, String rightTypeName)

Overrides net.bytebuddy.jar.asm.ClassWriter.getCommonSuperClass.

Doc from net.bytebuddy.jar.asm.ClassWriter.getCommonSuperClass.

Returns the common super type of the two given types. The default implementation of this method loads the two given classes and uses the java.lang.Class methods to find the common super class. It can be overridden to compute this common super type in other ways, in particular without actually loading any class, or to take into account the class that is currently being generated by this ClassWriter, which can of course not be loaded since it is under construction.

Parameters
leftTypeName:String

the internal name of a class (see Type#getInternalName()).

rightTypeName:String

the internal name of another class (see Type#getInternalName()).

Returns:String

the internal name of the common super class of the two given classes (see Type#getInternalName()).