T
- A loaded type that the built type is guaranteed to be a subclass of.public static interface DynamicType.Builder<T>
Modifier and Type | Interface and Description |
---|---|
static class |
DynamicType.Builder.AbstractBase<S>
An abstract base implementation of a dynamic type builder.
|
static interface |
DynamicType.Builder.FieldDefinition<S>
A builder for a field definition.
|
static interface |
DynamicType.Builder.InnerTypeDefinition<S>
An inner type definition for defining a type that is contained within another type, method or constructor.
|
static interface |
DynamicType.Builder.MethodDefinition<S>
A builder for a method definition.
|
static interface |
DynamicType.Builder.RecordComponentDefinition<S>
A builder for a record component definition.
|
static interface |
DynamicType.Builder.TypeVariableDefinition<S>
A builder for a type variable definition.
|
Modifier and Type | Method and Description |
---|---|
DynamicType.Builder<T> |
annotateType(Annotation... annotation)
Annotates the instrumented type with the supplied annotations.
|
DynamicType.Builder<T> |
annotateType(AnnotationDescription... annotation)
Annotates the instrumented type with the supplied annotations.
|
DynamicType.Builder<T> |
annotateType(Collection<? extends AnnotationDescription> annotations)
Annotates the instrumented type with the supplied annotations.
|
DynamicType.Builder<T> |
annotateType(List<? extends Annotation> annotations)
Annotates the instrumented type with the supplied annotations.
|
DynamicType.Builder<T> |
attribute(TypeAttributeAppender typeAttributeAppender)
Applies the given type attribute appender onto the instrumented type.
|
DynamicType.Builder.MethodDefinition.ImplementationDefinition<T> |
constructor(ElementMatcher<? super MethodDescription> matcher)
Matches a constructor that is already declared by the instrumented type.
|
DynamicType.Builder<T> |
declaredTypes(Class<?>... type)
Defines this type as an the outer type of the supplied types.
|
DynamicType.Builder<T> |
declaredTypes(Collection<? extends TypeDescription> types)
Defines this type as an the outer type of the supplied types.
|
DynamicType.Builder<T> |
declaredTypes(List<? extends Class<?>> types)
Defines this type as an the outer type of the supplied types.
|
DynamicType.Builder<T> |
declaredTypes(TypeDescription... type)
Defines this type as an the outer type of the supplied types.
|
DynamicType.Builder.MethodDefinition.ImplementationDefinition<T> |
define(Constructor<?> constructor)
Defines a constructor that is similar to the supplied constructor but without copying any annotations of the constructor or
constructor parameters.
|
DynamicType.Builder.FieldDefinition.Optional.Valuable<T> |
define(Field field)
Defines a field that is similar to the supplied field but without copying any annotations on the field.
|
DynamicType.Builder.FieldDefinition.Optional.Valuable<T> |
define(FieldDescription field)
Defines a field that is similar to the supplied field but without copying any annotations on the field.
|
DynamicType.Builder.MethodDefinition.ImplementationDefinition<T> |
define(Method method)
Defines a method that is similar to the supplied method but without copying any annotations of the method or method parameters.
|
DynamicType.Builder.MethodDefinition.ImplementationDefinition<T> |
define(MethodDescription methodDescription)
Defines a method or constructor that is similar to the supplied method description but without copying any annotations of
the method/constructor or method/constructor parameters.
|
DynamicType.Builder.RecordComponentDefinition.Optional<T> |
define(RecordComponentDescription recordComponentDescription)
Defines a new record component.
|
DynamicType.Builder.MethodDefinition.ParameterDefinition.Initial<T> |
defineConstructor(Collection<? extends ModifierContributor.ForMethod> modifierContributors)
Defines the specified constructor to be declared by the instrumented type.
|
DynamicType.Builder.MethodDefinition.ParameterDefinition.Initial<T> |
defineConstructor(int modifiers)
Defines the specified constructor to be declared by the instrumented type.
|
DynamicType.Builder.MethodDefinition.ParameterDefinition.Initial<T> |
defineConstructor(ModifierContributor.ForMethod... modifierContributor)
Defines the specified constructor to be declared by the instrumented type.
|
DynamicType.Builder.FieldDefinition.Optional.Valuable<T> |
defineField(String name,
Type type,
Collection<? extends ModifierContributor.ForField> modifierContributors)
Defines the specified field as a field of the built dynamic type.
|
DynamicType.Builder.FieldDefinition.Optional.Valuable<T> |
defineField(String name,
TypeDefinition type,
Collection<? extends ModifierContributor.ForField> modifierContributors)
Defines the specified field as a field of the built dynamic type.
|
DynamicType.Builder.FieldDefinition.Optional.Valuable<T> |
defineField(String name,
TypeDefinition type,
int modifiers)
Defines the specified field as a field of the built dynamic type.
|
DynamicType.Builder.FieldDefinition.Optional.Valuable<T> |
defineField(String name,
TypeDefinition type,
ModifierContributor.ForField... modifierContributor)
Defines the specified field as a field of the built dynamic type.
|
DynamicType.Builder.FieldDefinition.Optional.Valuable<T> |
defineField(String name,
Type type,
int modifiers)
Defines the specified field as a field of the built dynamic type.
|
DynamicType.Builder.FieldDefinition.Optional.Valuable<T> |
defineField(String name,
Type type,
ModifierContributor.ForField... modifierContributor)
Defines the specified field as a field of the built dynamic type.
|
DynamicType.Builder.MethodDefinition.ParameterDefinition.Initial<T> |
defineMethod(String name,
Type returnType,
Collection<? extends ModifierContributor.ForMethod> modifierContributors)
Defines the specified method to be declared by the instrumented type.
|
DynamicType.Builder.MethodDefinition.ParameterDefinition.Initial<T> |
defineMethod(String name,
TypeDefinition returnType,
Collection<? extends ModifierContributor.ForMethod> modifierContributors)
Defines the specified method to be declared by the instrumented type.
|
DynamicType.Builder.MethodDefinition.ParameterDefinition.Initial<T> |
defineMethod(String name,
TypeDefinition returnType,
int modifiers)
Defines the specified method to be declared by the instrumented type.
|
DynamicType.Builder.MethodDefinition.ParameterDefinition.Initial<T> |
defineMethod(String name,
TypeDefinition returnType,
ModifierContributor.ForMethod... modifierContributor)
Defines the specified method to be declared by the instrumented type.
|
DynamicType.Builder.MethodDefinition.ParameterDefinition.Initial<T> |
defineMethod(String name,
Type returnType,
int modifiers)
Defines the specified method to be declared by the instrumented type.
|
DynamicType.Builder.MethodDefinition.ParameterDefinition.Initial<T> |
defineMethod(String name,
Type returnType,
ModifierContributor.ForMethod... modifierContributor)
Defines the specified method to be declared by the instrumented type.
|
DynamicType.Builder.FieldDefinition.Optional<T> |
defineProperty(String name,
Type type)
Defines a Java bean property with the specified name.
|
DynamicType.Builder.FieldDefinition.Optional<T> |
defineProperty(String name,
Type type,
boolean readOnly)
Defines a Java bean property with the specified name.
|
DynamicType.Builder.FieldDefinition.Optional<T> |
defineProperty(String name,
TypeDefinition type)
Defines a Java bean property with the specified name.
|
DynamicType.Builder.FieldDefinition.Optional<T> |
defineProperty(String name,
TypeDefinition type,
boolean readOnly)
Defines a Java bean property with the specified name.
|
DynamicType.Builder.RecordComponentDefinition.Optional<T> |
defineRecordComponent(String name,
Type type)
Defines a new record component.
|
DynamicType.Builder.RecordComponentDefinition.Optional<T> |
defineRecordComponent(String name,
TypeDefinition type)
Defines a new record component.
|
DynamicType.Builder.FieldDefinition.Valuable<T> |
field(ElementMatcher<? super FieldDescription> matcher)
Matches a field that is already declared by the instrumented type.
|
DynamicType.Builder.FieldDefinition.Valuable<T> |
field(LatentMatcher<? super FieldDescription> matcher)
Matches a field that is already declared by the instrumented type.
|
DynamicType.Builder<T> |
ignoreAlso(ElementMatcher<? super MethodDescription> ignoredMethods)
Specifies to exclude any method that is matched by the supplied matcher from instrumentation.
|
DynamicType.Builder<T> |
ignoreAlso(LatentMatcher<? super MethodDescription> ignoredMethods)
Specifies to exclude any method that is matched by the supplied matcher from instrumentation.
|
DynamicType.Builder.MethodDefinition.ImplementationDefinition.Optional<T> |
implement(Collection<? extends TypeDefinition> interfaceTypes)
Implements the supplied interfaces for the instrumented type.
|
DynamicType.Builder.MethodDefinition.ImplementationDefinition.Optional<T> |
implement(List<? extends Type> interfaceTypes)
Implements the supplied interfaces for the instrumented type.
|
DynamicType.Builder.MethodDefinition.ImplementationDefinition.Optional<T> |
implement(Type... interfaceType)
Implements the supplied interfaces for the instrumented type.
|
DynamicType.Builder.MethodDefinition.ImplementationDefinition.Optional<T> |
implement(TypeDefinition... interfaceType)
Implements the supplied interfaces for the instrumented type.
|
DynamicType.Builder<T> |
initializer(ByteCodeAppender byteCodeAppender)
Executes the supplied byte code appender within the beginning of the instrumented type's type initializer.
|
DynamicType.Builder<T> |
initializer(LoadedTypeInitializer loadedTypeInitializer)
Executes the supplied loaded type initializer when loading the created instrumented type.
|
DynamicType.Builder.InnerTypeDefinition.ForType<T> |
innerTypeOf(Class<?> type)
Defines this type as an inner type of the supplied type.
|
DynamicType.Builder.InnerTypeDefinition<T> |
innerTypeOf(Constructor<?> constructor)
Defines this type as an inner type that was declared within the supplied constructor.
|
DynamicType.Builder.InnerTypeDefinition<T> |
innerTypeOf(Method method)
Defines this type as an inner type that was declared within the supplied method.
|
DynamicType.Builder.InnerTypeDefinition<T> |
innerTypeOf(MethodDescription.InDefinedShape methodDescription)
Defines this type as an inner type that was declared within the supplied method or constructor.
|
DynamicType.Builder.InnerTypeDefinition.ForType<T> |
innerTypeOf(TypeDescription type)
Defines this type as an inner type of the supplied type.
|
DynamicType.Builder.MethodDefinition.ImplementationDefinition<T> |
invokable(ElementMatcher<? super MethodDescription> matcher)
Matches a method or constructor that is already declared or inherited by the instrumented type.
|
DynamicType.Builder.MethodDefinition.ImplementationDefinition<T> |
invokable(LatentMatcher<? super MethodDescription> matcher)
Matches a method or constructor that is already declared or inherited by the instrumented type.
|
DynamicType.Unloaded<T> |
make()
Creates the dynamic type this builder represents.
|
DynamicType.Unloaded<T> |
make(TypePool typePool)
Creates the dynamic type this builder represents.
|
DynamicType.Unloaded<T> |
make(TypeResolutionStrategy typeResolutionStrategy)
Creates the dynamic type this builder represents.
|
DynamicType.Unloaded<T> |
make(TypeResolutionStrategy typeResolutionStrategy,
TypePool typePool)
Creates the dynamic type this builder represents.
|
DynamicType.Builder<T> |
merge(Collection<? extends ModifierContributor.ForType> modifierContributors)
Merges the supplied modifier contributors with the modifiers of the instrumented type and defines them as the instrumented
type's new modifiers.
|
DynamicType.Builder<T> |
merge(ModifierContributor.ForType... modifierContributor)
Merges the supplied modifier contributors with the modifiers of the instrumented type and defines them as the instrumented
type's new modifiers.
|
DynamicType.Builder.MethodDefinition.ImplementationDefinition<T> |
method(ElementMatcher<? super MethodDescription> matcher)
Matches a method that is already declared or inherited by the instrumented type.
|
DynamicType.Builder<T> |
modifiers(Collection<? extends ModifierContributor.ForType> modifierContributors)
Defines the supplied modifiers as the modifiers of the instrumented type.
|
DynamicType.Builder<T> |
modifiers(int modifiers)
Defines the supplied modifiers as the modifiers of the instrumented type.
|
DynamicType.Builder<T> |
modifiers(ModifierContributor.ForType... modifierContributor)
Defines the supplied modifiers as the modifiers of the instrumented type.
|
DynamicType.Builder<T> |
name(String name)
Names the dynamic type by the supplied name.
|
DynamicType.Builder<T> |
nestHost(Class<?> type)
Defines this type as a nest member of the supplied type as a nest host.
|
DynamicType.Builder<T> |
nestHost(TypeDescription type)
Defines this type as a nest member of the supplied type as a nest host.
|
DynamicType.Builder<T> |
nestMembers(Class<?>... type)
Defines this type as a nest host for the supplied types.
|
DynamicType.Builder<T> |
nestMembers(Collection<? extends TypeDescription> types)
Defines this type as a nest host for the supplied types.
|
DynamicType.Builder<T> |
nestMembers(List<? extends Class<?>> types)
Defines this type as a nest host for the supplied types.
|
DynamicType.Builder<T> |
nestMembers(TypeDescription... type)
Defines this type as a nest host for the supplied types.
|
DynamicType.Builder<T> |
noNestMate()
Defines this type as self-hosted, i.e.
|
DynamicType.Builder<T> |
permittedSubclass(Class<?>... type)
Defines this type to allow the supplied permitted subclasses additionally to any prior permitted subclasses.
|
DynamicType.Builder<T> |
permittedSubclass(Collection<? extends TypeDescription> types)
Defines this type to allow the supplied permitted subclasses additionally to any prior permitted subclasses.
|
DynamicType.Builder<T> |
permittedSubclass(List<? extends Class<?>> types)
Defines this type to allow the supplied permitted subclasses additionally to any prior permitted subclasses.
|
DynamicType.Builder<T> |
permittedSubclass(TypeDescription... type)
Defines this type to allow the supplied permitted subclasses additionally to any prior permitted subclasses.
|
DynamicType.Builder.RecordComponentDefinition<T> |
recordComponent(ElementMatcher<? super RecordComponentDescription> matcher)
Matches a record component that is already declared by the instrumented type.
|
DynamicType.Builder.RecordComponentDefinition<T> |
recordComponent(LatentMatcher<? super RecordComponentDescription> matcher)
Matches a record component that is already declared by the instrumented type.
|
DynamicType.Builder<T> |
require(Collection<DynamicType> auxiliaryTypes)
Explicitly requires other dynamic types for the creation of this type.
|
DynamicType.Builder<T> |
require(DynamicType... auxiliaryType)
Explicitly requires other dynamic types for the creation of this type.
|
DynamicType.Builder<T> |
require(TypeDescription type,
byte[] binaryRepresentation)
Explicitly requires another dynamic type for the creation of this type.
|
DynamicType.Builder<T> |
require(TypeDescription type,
byte[] binaryRepresentation,
LoadedTypeInitializer typeInitializer)
Explicitly requires another dynamic type for the creation of this type.
|
DynamicType.Builder.FieldDefinition.Optional<T> |
serialVersionUid(long serialVersionUid)
Defines a private, static, final field for a serial version UID of the given value.
|
DynamicType.Builder<T> |
suffix(String suffix)
Adds a suffix to the current type name without changing the type's package.
|
DynamicType.Builder<T> |
topLevelType()
Defines this type as a top-level type that is not declared by another type or enclosed by another member.
|
TypeDescription |
toTypeDescription()
Returns a
TypeDescription for the currently built type. |
DynamicType.Builder<T> |
transform(ElementMatcher<? super TypeDescription.Generic> matcher,
Transformer<TypeVariableToken> transformer)
Transforms any type variable that is defined by this type if it is matched by the supplied matcher.
|
DynamicType.Builder.TypeVariableDefinition<T> |
typeVariable(String symbol)
Defines the supplied type variable without any bounds as a type variable of the instrumented type.
|
DynamicType.Builder.TypeVariableDefinition<T> |
typeVariable(String symbol,
Collection<? extends TypeDefinition> bounds)
Defines the supplied type variable with the given bound as a type variable of the instrumented type.
|
DynamicType.Builder.TypeVariableDefinition<T> |
typeVariable(String symbol,
List<? extends Type> bounds)
Defines the supplied type variable with the given bound as a type variable of the instrumented type.
|
DynamicType.Builder.TypeVariableDefinition<T> |
typeVariable(String symbol,
Type... bound)
Defines the supplied type variable with the given bound as a type variable of the instrumented type.
|
DynamicType.Builder.TypeVariableDefinition<T> |
typeVariable(String symbol,
TypeDefinition... bound)
Defines the supplied type variable with the given bound as a type variable of the instrumented type.
|
DynamicType.Builder<T> |
unsealed()
Unseales this type.
|
DynamicType.Builder<T> |
visit(AsmVisitorWrapper asmVisitorWrapper)
Applies the supplied
AsmVisitorWrapper onto the ClassVisitor during building a dynamic type. |
DynamicType.Builder<T> |
withHashCodeEquals()
Implements
Object.hashCode() and Object.equals(Object) methods for the instrumented type if those
methods are not declared as final by a super class. |
DynamicType.Builder<T> |
withToString()
Implements a
Object.toString() method for the instrumented type if such a method is not declared as final
by a super class. |
ContextClassVisitor |
wrap(ClassVisitor classVisitor)
Wraps a class visitor with the configuration that is represented by this dynamic type builder, using a
default
TypePool . |
ContextClassVisitor |
wrap(ClassVisitor classVisitor,
int writerFlags,
int readerFlags)
Wraps a class visitor with the configuration that is represented by this dynamic type builder, using a
default
TypePool . |
ContextClassVisitor |
wrap(ClassVisitor classVisitor,
TypePool typePool)
Wraps a class visitor with the configuration that is represented by this dynamic type builder.
|
ContextClassVisitor |
wrap(ClassVisitor classVisitor,
TypePool typePool,
int writerFlags,
int readerFlags)
Wraps a class visitor with the configuration that is represented by this dynamic type builder.
|
DynamicType.Builder<T> visit(AsmVisitorWrapper asmVisitorWrapper)
AsmVisitorWrapper
onto the ClassVisitor
during building a dynamic type.
Using an ASM visitor, it is possible to manipulate byte code directly. Byte Buddy does not validate directly created byte code
and it remains the responsibility of the visitor's implementor to generate legal byte code. If several ASM visitor wrappers
are registered, they are applied on top of another in their registration order.asmVisitorWrapper
- The ASM visitor wrapper to apply duringDynamicType.Builder<T> name(String name)
foo.Bar
). A type's package determines what other types are visible to the instrumented type and what methods
can be overridden or be represented in method signatures or as field types.name
- The fully qualified name of the generated class in a binary format.DynamicType.Builder<T> suffix(String suffix)
suffix
- The suffix to append to the current type name.DynamicType.Builder<T> modifiers(ModifierContributor.ForType... modifierContributor)
modifierContributor
- The modifiers of the instrumented type.DynamicType.Builder<T> modifiers(Collection<? extends ModifierContributor.ForType> modifierContributors)
modifierContributors
- The modifiers of the instrumented type.DynamicType.Builder<T> modifiers(int modifiers)
modifiers
- The modifiers of the instrumented type.DynamicType.Builder<T> merge(ModifierContributor.ForType... modifierContributor)
modifierContributor
- The modifiers of the instrumented type.DynamicType.Builder<T> merge(Collection<? extends ModifierContributor.ForType> modifierContributors)
modifierContributors
- The modifiers of the instrumented type.DynamicType.Builder<T> topLevelType()
Defines this type as a top-level type that is not declared by another type or enclosed by another member.
Important: Changing the declaration hierarchy of a type has no influence on the nest mate hierarchy.
Warning: By changing this type's declaration, any other type will not change its declaration of enclosing members or declared types about any nesting of a declaration. It is the responsibility of the user of this API to keep such declarations consistent among the definitions of connected types.
DynamicType.Builder.InnerTypeDefinition.ForType<T> innerTypeOf(Class<?> type)
Defines this type as an inner type of the supplied type. Without any additional configuration, the type declaration is defined as a local type.
Important: Changing the declaration hierarchy of a type has no influence on the nest mate hierarchy.
Warning: By changing this type's declaration, any other type will not change its declaration of enclosing members or declared types about any nesting of a declaration. It is the responsibility of the user of this API to keep such declarations consistent among the definitions of connected types.
type
- The type to declare as the built type's outer type.DynamicType.Builder.InnerTypeDefinition.ForType<T> innerTypeOf(TypeDescription type)
Defines this type as an inner type of the supplied type. Without any additional configuration, the type declaration is defined as a local type.
Important: Changing the declaration hierarchy of a type has no influence on the nest mate hierarchy.
Warning: By changing this type's declaration, any other type will not change its declaration of enclosing members or declared types about any nesting of a declaration. It is the responsibility of the user of this API to keep such declarations consistent among the definitions of connected types.
type
- The type to declare as the built type's outer type.DynamicType.Builder.InnerTypeDefinition<T> innerTypeOf(Method method)
Defines this type as an inner type that was declared within the supplied method. Without any additional configuration, the type declaration is defined as a local type.
Important: Changing the declaration hierarchy of a type has no influence on the nest mate hierarchy.
Warning: By changing this type's declaration, any other type will not change its declaration of enclosing members or declared types about any nesting of a declaration. It is the responsibility of the user of this API to keep such declarations consistent among the definitions of connected types.
method
- The method to declare as the built type's declaring method.DynamicType.Builder.InnerTypeDefinition<T> innerTypeOf(Constructor<?> constructor)
Defines this type as an inner type that was declared within the supplied constructor. Without any additional configuration, the type declaration is defined as a local type.
Important: Changing the declaration hierarchy of a type has no influence on the nest mate hierarchy.
Warning: By changing this type's declaration, any other type will not change its declaration of enclosing members or declared types about any nesting of a declaration. It is the responsibility of the user of this API to keep such declarations consistent among the definitions of connected types.
constructor
- The constructor to declare as the built type's declaring method.DynamicType.Builder.InnerTypeDefinition<T> innerTypeOf(MethodDescription.InDefinedShape methodDescription)
Defines this type as an inner type that was declared within the supplied method or constructor. Without any additional configuration, the type declaration is defined as a local type.
Important: Changing the declaration hierarchy of a type has no influence on the nest mate hierarchy.
Warning: By changing this type's declaration, any other type will not change its declaration of enclosing members or declared types about any nesting of a declaration. It is the responsibility of the user of this API to keep such declarations consistent among the definitions of connected types.
methodDescription
- The method or constructor to declare as the built type's declaring method.DynamicType.Builder<T> declaredTypes(Class<?>... type)
Defines this type as an the outer type of the supplied types. Using this method, it is possible to add inner type declarations for anonymous or local types which are not normally exposed by type descriptions. Doing so, it is however possible to indicate to Byte Buddy that the required attributes for such an inner type declaration should be added to a class file.
Important: Changing the declaration hierarchy of a type has no influence on the nest mate hierarchy.
Warning: By changing this type's declaration, any other type will not change its declaration of enclosing members or declared types about any nesting of a declaration. It is the responsibility of the user of this API to keep such declarations consistent among the definitions of connected types.
type
- The types being declared.DynamicType.Builder<T> declaredTypes(TypeDescription... type)
Defines this type as an the outer type of the supplied types. Using this method, it is possible to add inner type declarations for anonymous or local types which are not normally exposed by type descriptions. Doing so, it is however possible to indicate to Byte Buddy that the required attributes for such an inner type declaration should be added to a class file.
Important: Changing the declaration hierarchy of a type has no influence on the nest mate hierarchy.
Warning: By changing this type's declaration, any other type will not change its declaration of enclosing members or declared types about any nesting of a declaration. It is the responsibility of the user of this API to keep such declarations consistent among the definitions of connected types.
type
- The types being declared.DynamicType.Builder<T> declaredTypes(List<? extends Class<?>> types)
Defines this type as an the outer type of the supplied types. Using this method, it is possible to add inner type declarations for anonymous or local types which are not normally exposed by type descriptions. Doing so, it is however possible to indicate to Byte Buddy that the required attributes for such an inner type declaration should be added to a class file.
Important: Changing the declaration hierarchy of a type has no influence on the nest mate hierarchy.
Warning: By changing this type's declaration, any other type will not change its declaration of enclosing members or declared types about any nesting of a declaration. It is the responsibility of the user of this API to keep such declarations consistent among the definitions of connected types.
types
- The types being declared.DynamicType.Builder<T> declaredTypes(Collection<? extends TypeDescription> types)
Defines this type as an the outer type of the supplied types. Using this method, it is possible to add inner type declarations for anonymous or local types which are not normally exposed by type descriptions. Doing so, it is however possible to indicate to Byte Buddy that the required attributes for such an inner type declaration should be added to a class file.
Important: Changing the declaration hierarchy of a type has no influence on the nest mate hierarchy.
Warning: By changing this type's declaration, any other type will not change its declaration of enclosing members or declared types about any nesting of a declaration. It is the responsibility of the user of this API to keep such declarations consistent among the definitions of connected types.
types
- The types being declared.DynamicType.Builder<T> noNestMate()
Defines this type as self-hosted, i.e. as only being a nest mate of itself.
Important: Changing the nest mate hierarchy of a type has no influence on the declaration hierarchy.
Warning: Changing nest mate hierarchies always requires changing a member and its host or a host and all its members. Otherwise, the runtime will not accept further nest mates. It is the responsibility of the user of this API to keep such declarations consistent among the definitions of connected types.
DynamicType.Builder<T> nestHost(Class<?> type)
Defines this type as a nest member of the supplied type as a nest host.
Important: Changing the nest mate hierarchy of a type has no influence on the declaration hierarchy.
Warning: Changing nest mate hierarchies always requires changing a member and its host or a host and all its members. Otherwise, the runtime will not accept further nest mates. It is the responsibility of the user of this API to keep such declarations consistent among the definitions of connected types.
type
- The nest host.DynamicType.Builder<T> nestHost(TypeDescription type)
Defines this type as a nest member of the supplied type as a nest host.
Important: Changing the nest mate hierarchy of a type has no influence on the declaration hierarchy.
Warning: Changing nest mate hierarchies always requires changing a member and its host or a host and all its members. Otherwise, the runtime will not accept further nest mates. It is the responsibility of the user of this API to keep such declarations consistent among the definitions of connected types.
type
- The nest host.DynamicType.Builder<T> nestMembers(Class<?>... type)
Defines this type as a nest host for the supplied types.
Important: Changing the nest mate hierarchy of a type has no influence on the declaration hierarchy.
Warning: Changing nest mate hierarchies always requires changing a member and its host or a host and all its members. Otherwise, the runtime will not accept further nest mates. It is the responsibility of the user of this API to keep such declarations consistent among the definitions of connected types.
type
- The nest members.DynamicType.Builder<T> nestMembers(TypeDescription... type)
Defines this type as a nest host for the supplied types.
Important: Changing the nest mate hierarchy of a type has no influence on the declaration hierarchy.
Warning: Changing nest mate hierarchies always requires changing a member and its host or a host and all its members. Otherwise, the runtime will not accept further nest mates. It is the responsibility of the user of this API to keep such declarations consistent among the definitions of connected types.
type
- The nest members.DynamicType.Builder<T> nestMembers(List<? extends Class<?>> types)
Defines this type as a nest host for the supplied types.
Important: Changing the nest mate hierarchy of a type has no influence on the declaration hierarchy.
Warning: Changing nest mate hierarchies always requires changing a member and its host or a host and all its members. Otherwise, the runtime will not accept further nest mates. It is the responsibility of the user of this API to keep such declarations consistent among the definitions of connected types.
types
- The nest members.DynamicType.Builder<T> nestMembers(Collection<? extends TypeDescription> types)
Defines this type as a nest host for the supplied types.
Important: Changing the nest mate hierarchy of a type has no influence on the declaration hierarchy.
Warning: Changing nest mate hierarchies always requires changing a member and its host or a host and all its members. Otherwise, the runtime will not accept further nest mates. It is the responsibility of the user of this API to keep such declarations consistent among the definitions of connected types.
types
- The nest members.DynamicType.Builder<T> permittedSubclass(Class<?>... type)
type
- The permitted subclasses.DynamicType.Builder<T> permittedSubclass(TypeDescription... type)
type
- The permitted subclasses.DynamicType.Builder<T> permittedSubclass(List<? extends Class<?>> types)
types
- The permitted subclasses.DynamicType.Builder<T> permittedSubclass(Collection<? extends TypeDescription> types)
types
- The permitted subclasses.DynamicType.Builder<T> unsealed()
DynamicType.Builder<T> attribute(TypeAttributeAppender typeAttributeAppender)
Annotation
s.typeAttributeAppender
- The type attribute appender to apply.DynamicType.Builder<T> annotateType(Annotation... annotation)
annotation
- The annotations to add to the instrumented type.DynamicType.Builder<T> annotateType(List<? extends Annotation> annotations)
annotations
- The annotations to add to the instrumented type.DynamicType.Builder<T> annotateType(AnnotationDescription... annotation)
annotation
- The annotations to add to the instrumented type.DynamicType.Builder<T> annotateType(Collection<? extends AnnotationDescription> annotations)
annotations
- The annotations to add to the instrumented type.DynamicType.Builder.MethodDefinition.ImplementationDefinition.Optional<T> implement(Type... interfaceType)
Implements the supplied interfaces for the instrumented type. Optionally, it is possible to define the methods that are defined by the interfaces or the interfaces' super interfaces. This excludes methods that are explicitly ignored.
Note: This methods implements the supplied types as is, i.e. any Class
values are implemented
as raw types if they declare type variables or an owner type.
interfaceType
- The interface types to implement.DynamicType.Builder.MethodDefinition.ImplementationDefinition.Optional<T> implement(List<? extends Type> interfaceTypes)
Implements the supplied interfaces for the instrumented type. Optionally, it is possible to define the methods that are defined by the interfaces or the interfaces' super interfaces. This excludes methods that are explicitly ignored.
Note: This methods implements the supplied types as is, i.e. any Class
values are implemented
as raw types if they declare type variables or an owner type.
interfaceTypes
- The interface types to implement.DynamicType.Builder.MethodDefinition.ImplementationDefinition.Optional<T> implement(TypeDefinition... interfaceType)
Implements the supplied interfaces for the instrumented type. Optionally, it is possible to define the methods that are defined by the interfaces or the interfaces' super interfaces. This excludes methods that are explicitly ignored.
Note: This methods implements the supplied types as is, i.e. any TypeDescription
values are
implemented as raw types if they declare type variables or an owner type.
interfaceType
- The interface types to implement.DynamicType.Builder.MethodDefinition.ImplementationDefinition.Optional<T> implement(Collection<? extends TypeDefinition> interfaceTypes)
Implements the supplied interfaces for the instrumented type. Optionally, it is possible to define the methods that are defined by the interfaces or the interfaces' super interfaces. This excludes methods that are explicitly ignored.
Note: This methods implements the supplied types as is, i.e. any TypeDescription
values are
implemented as raw types if they declare type variables or an owner type.
interfaceTypes
- The interface types to implement.DynamicType.Builder<T> initializer(ByteCodeAppender byteCodeAppender)
Executes the supplied byte code appender within the beginning of the instrumented type's type initializer. The supplied byte code appender must not return from the method. If several byte code appenders are supplied, they are executed within their application order.
This method should only be used for preparing an instrumented type with a specific configuration. Normally,
a byte code appender is applied via Byte Buddy's standard API by invoking invokable(ElementMatcher)
using the ElementMatchers.isTypeInitializer()
matcher.
byteCodeAppender
- The byte code appender to execute within the instrumented type's type initializer.DynamicType.Builder<T> initializer(LoadedTypeInitializer loadedTypeInitializer)
loadedTypeInitializer
- The loaded type initializer to execute upon loading the instrumented type.DynamicType.Builder<T> require(TypeDescription type, byte[] binaryRepresentation)
type
- The type to require.binaryRepresentation
- The type's binary representation.DynamicType.Builder<T> require(TypeDescription type, byte[] binaryRepresentation, LoadedTypeInitializer typeInitializer)
type
- The type to require.binaryRepresentation
- The type's binary representation.typeInitializer
- The type's loaded type initializer.DynamicType.Builder<T> require(DynamicType... auxiliaryType)
auxiliaryType
- The required dynamic types.DynamicType.Builder<T> require(Collection<DynamicType> auxiliaryTypes)
auxiliaryTypes
- The required dynamic types.DynamicType.Builder.TypeVariableDefinition<T> typeVariable(String symbol)
symbol
- The type variable's symbol.DynamicType.Builder.TypeVariableDefinition<T> typeVariable(String symbol, Type... bound)
symbol
- The type variable's symbol.bound
- The type variable's upper bounds. Can also be TargetType
if the bound type
should be equal to the currently instrumented type.DynamicType.Builder.TypeVariableDefinition<T> typeVariable(String symbol, List<? extends Type> bounds)
symbol
- The type variable's symbol.bounds
- The type variable's upper bounds. Can also be TargetType
if the bound type
should be equal to the currently instrumented type.DynamicType.Builder.TypeVariableDefinition<T> typeVariable(String symbol, TypeDefinition... bound)
symbol
- The type variable's symbol.bound
- The type variable's upper bounds. Can also be TargetType
if the bound type
should be equal to the currently instrumented type.DynamicType.Builder.TypeVariableDefinition<T> typeVariable(String symbol, Collection<? extends TypeDefinition> bounds)
symbol
- The type variable's symbol.bounds
- The type variable's upper bounds. Can also be TargetType
if the bound type
should be equal to the currently instrumented type.DynamicType.Builder<T> transform(ElementMatcher<? super TypeDescription.Generic> matcher, Transformer<TypeVariableToken> transformer)
matcher
- The matcher to decide what type variables to transform.transformer
- The transformer to apply to the matched type variables.DynamicType.Builder.FieldDefinition.Optional.Valuable<T> defineField(String name, Type type, ModifierContributor.ForField... modifierContributor)
name
- The name of the field.type
- The type of the field. Can also be TargetType
if the field type
should be equal to the currently instrumented type.modifierContributor
- The modifiers of the field.DynamicType.Builder.FieldDefinition.Optional.Valuable<T> defineField(String name, Type type, Collection<? extends ModifierContributor.ForField> modifierContributors)
name
- The name of the field.type
- The type of the field. Can also be TargetType
if the field type
should be equal to the currently instrumented type.modifierContributors
- The modifiers of the field.DynamicType.Builder.FieldDefinition.Optional.Valuable<T> defineField(String name, Type type, int modifiers)
name
- The name of the field.type
- The type of the field. Can also be TargetType
if the field type
should be equal to the currently instrumented type.modifiers
- The modifiers of the field.DynamicType.Builder.FieldDefinition.Optional.Valuable<T> defineField(String name, TypeDefinition type, ModifierContributor.ForField... modifierContributor)
name
- The name of the field.type
- The type of the field. Can also be TargetType
if the field type
should be equal to the currently instrumented type.modifierContributor
- The modifiers of the field.DynamicType.Builder.FieldDefinition.Optional.Valuable<T> defineField(String name, TypeDefinition type, Collection<? extends ModifierContributor.ForField> modifierContributors)
name
- The name of the field.type
- The type of the field. Can also be TargetType
if the field type
should be equal to the currently instrumented type.modifierContributors
- The modifiers of the field.DynamicType.Builder.FieldDefinition.Optional.Valuable<T> defineField(String name, TypeDefinition type, int modifiers)
name
- The name of the field.type
- The type of the field. Can also be TargetType
if the field type
should be equal to the currently instrumented type.modifiers
- The modifiers of the field.DynamicType.Builder.FieldDefinition.Optional.Valuable<T> define(Field field)
field
- The field to imitate as a field of the instrumented type.DynamicType.Builder.FieldDefinition.Optional.Valuable<T> define(FieldDescription field)
field
- The field to imitate as a field of the instrumented type.DynamicType.Builder.FieldDefinition.Optional<T> serialVersionUid(long serialVersionUid)
serialVersionUid
- The serial version UID to define as a value.DynamicType.Builder.FieldDefinition.Valuable<T> field(ElementMatcher<? super FieldDescription> matcher)
Matches a field that is already declared by the instrumented type. This gives opportunity to change that field's default value, annotations or custom attributes.
When a type is redefined or rebased, any annotations that the field declared previously is preserved
as it is if Byte Buddy is configured to retain such annotations by
AnnotationRetention.ENABLED
. If any existing annotations should be
altered, annotation retention must be disabled.
If a field is already matched by a previously specified field matcher, the new field definition gets precedence over the previous definition, i.e. the previous field definition is no longer applied.
matcher
- The matcher that determines what declared fields are affected by the subsequent specification.DynamicType.Builder.FieldDefinition.Valuable<T> field(LatentMatcher<? super FieldDescription> matcher)
Matches a field that is already declared by the instrumented type. This gives opportunity to change that field's
default value, annotations or custom attributes. Using a latent matcher gives opportunity to resolve an
ElementMatcher
based on the instrumented type before applying the matcher.
When a type is redefined or rebased, any annotations that the field declared previously is preserved
as it is if Byte Buddy is configured to retain such annotations by
AnnotationRetention.ENABLED
. If any existing annotations should be
altered, annotation retention must be disabled.
If a field is already matched by a previously specified field matcher, the new field definition gets precedence over the previous definition, i.e. the previous field definition is no longer applied.
matcher
- The matcher that determines what declared fields are affected by the subsequent specification.DynamicType.Builder<T> ignoreAlso(ElementMatcher<? super MethodDescription> ignoredMethods)
Specifies to exclude any method that is matched by the supplied matcher from instrumentation. Previously supplied matchers remain valid after supplying a new matcher, i.e. any method that is matched by a previously supplied matcher is always ignored.
When ignoring a type, previously registered matchers are applied before this matcher. If a previous matcher indicates that a type is to be ignored, this matcher is no longer executed.
ignoredMethods
- The matcher for determining what methods to exclude from instrumentation.DynamicType.Builder<T> ignoreAlso(LatentMatcher<? super MethodDescription> ignoredMethods)
Specifies to exclude any method that is matched by the supplied matcher from instrumentation. Previously supplied matchers
remain valid after supplying a new matcher, i.e. any method that is matched by a previously supplied matcher is always ignored.
Using a latent matcher gives opportunity to resolve an ElementMatcher
based on the instrumented type before applying the
matcher.
When ignoring a type, previously registered matchers are applied before this matcher. If a previous matcher indicates that a type is to be ignored, this matcher is no longer executed.
ignoredMethods
- The matcher for determining what methods to exclude from instrumentation.DynamicType.Builder.MethodDefinition.ParameterDefinition.Initial<T> defineMethod(String name, Type returnType, ModifierContributor.ForMethod... modifierContributor)
name
- The name of the method.returnType
- The method's return type. Can also be TargetType
if the return type
should be equal to the currently instrumented type.modifierContributor
- The method's modifiers.DynamicType.Builder.MethodDefinition.ParameterDefinition.Initial<T> defineMethod(String name, Type returnType, Collection<? extends ModifierContributor.ForMethod> modifierContributors)
name
- The name of the method.returnType
- The method's return type. Can also be TargetType
if the return type
should be equal to the currently instrumented type.modifierContributors
- The method's modifiers.DynamicType.Builder.MethodDefinition.ParameterDefinition.Initial<T> defineMethod(String name, Type returnType, int modifiers)
name
- The name of the method.returnType
- The method's return type. Can also be TargetType
if the return type
should be equal to the currently instrumented type.modifiers
- The method's modifiers.DynamicType.Builder.MethodDefinition.ParameterDefinition.Initial<T> defineMethod(String name, TypeDefinition returnType, ModifierContributor.ForMethod... modifierContributor)
name
- The name of the method.returnType
- The method's return type. Can also be TargetType
if the return type
should be equal to the currently instrumented type.modifierContributor
- The method's modifiers.DynamicType.Builder.MethodDefinition.ParameterDefinition.Initial<T> defineMethod(String name, TypeDefinition returnType, Collection<? extends ModifierContributor.ForMethod> modifierContributors)
name
- The name of the method.returnType
- The method's return type. Can also be TargetType
if the return type
should be equal to the currently instrumented type.modifierContributors
- The method's modifiers.DynamicType.Builder.MethodDefinition.ParameterDefinition.Initial<T> defineMethod(String name, TypeDefinition returnType, int modifiers)
name
- The name of the method.returnType
- The method's return type. Can also be TargetType
if the return type
should be equal to the currently instrumented type.modifiers
- The method's modifiers.DynamicType.Builder.MethodDefinition.ParameterDefinition.Initial<T> defineConstructor(ModifierContributor.ForMethod... modifierContributor)
modifierContributor
- The constructor's modifiers.DynamicType.Builder.MethodDefinition.ParameterDefinition.Initial<T> defineConstructor(Collection<? extends ModifierContributor.ForMethod> modifierContributors)
modifierContributors
- The constructor's modifiers.DynamicType.Builder.MethodDefinition.ParameterDefinition.Initial<T> defineConstructor(int modifiers)
modifiers
- The constructor's modifiers.DynamicType.Builder.MethodDefinition.ImplementationDefinition<T> define(Method method)
method
- The method to imitate as a method of the instrumented type.DynamicType.Builder.MethodDefinition.ImplementationDefinition<T> define(Constructor<?> constructor)
constructor
- The constructor to imitate as a method of the instrumented type.DynamicType.Builder.MethodDefinition.ImplementationDefinition<T> define(MethodDescription methodDescription)
methodDescription
- The method description to imitate as a method or constructor of the instrumented type.DynamicType.Builder.FieldDefinition.Optional<T> defineProperty(String name, Type type)
name
- The name of the property.type
- The property type.DynamicType.Builder.FieldDefinition.Optional<T> defineProperty(String name, Type type, boolean readOnly)
name
- The name of the property.type
- The property type.readOnly
- true
if the property is read only, i.e. no setter should be defined and the field should be final
.DynamicType.Builder.FieldDefinition.Optional<T> defineProperty(String name, TypeDefinition type)
name
- The name of the property.type
- The property type.DynamicType.Builder.FieldDefinition.Optional<T> defineProperty(String name, TypeDefinition type, boolean readOnly)
name
- The name of the property.type
- The property type.readOnly
- true
if the property is read only, i.e. no setter should be defined and the field should be final
.DynamicType.Builder.MethodDefinition.ImplementationDefinition<T> method(ElementMatcher<? super MethodDescription> matcher)
Matches a method that is already declared or inherited by the instrumented type. This gives opportunity to change or to override that method's implementation, default value, annotations or custom attributes. It is also possible to make a method abstract.
When a type is redefined or rebased, any annotations that the method declared previously is preserved
as it is if Byte Buddy is configured to retain such annotations by
AnnotationRetention.ENABLED
. If any existing annotations should be
altered, annotation retention must be disabled.
If a method is already matched by a previously specified matcher, the new method definition gets precedence over the previous definition, i.e. the previous method definition is no longer applied.
Note that the specified definition does never apply for methods that are explicitly ignored.
matcher
- The matcher that determines what methods are affected by the subsequent specification.DynamicType.Builder.MethodDefinition.ImplementationDefinition<T> constructor(ElementMatcher<? super MethodDescription> matcher)
Matches a constructor that is already declared by the instrumented type. This gives opportunity to change that constructor's implementation, default value, annotations or custom attributes.
When a type is redefined or rebased, any annotations that the constructor declared previously is preserved
as it is if Byte Buddy is configured to retain such annotations by
AnnotationRetention.ENABLED
. If any existing annotations should be
altered, annotation retention must be disabled.
If a constructor is already matched by a previously specified matcher, the new constructor definition gets precedence over the previous definition, i.e. the previous constructor definition is no longer applied.
Note that the specified definition does never apply for methods that are explicitly ignored.
matcher
- The matcher that determines what constructors are affected by the subsequent specification.DynamicType.Builder.MethodDefinition.ImplementationDefinition<T> invokable(ElementMatcher<? super MethodDescription> matcher)
Matches a method or constructor that is already declared or inherited by the instrumented type. This gives opportunity to change or to override that method's or constructor's implementation, default value, annotations or custom attributes. It is also possible to make a method abstract.
When a type is redefined or rebased, any annotations that the method or constructor declared previously is preserved
as it is if Byte Buddy is configured to retain such annotations by
AnnotationRetention.ENABLED
. If any existing annotations should be
altered, annotation retention must be disabled.
If a method or constructor is already matched by a previously specified matcher, the new definition gets precedence over the previous definition, i.e. the previous definition is no longer applied.
Note that the specified definition does never apply for methods that are explicitly ignored.
Important: It is possible to instrument the dynamic type's initializer. Depending on the used TypeResolutionStrategy
,
the type initializer might be run before Byte Buddy could apply any LoadedTypeInitializer
s which are
responsible for preparing the instrumented type prior to the initializer's execution. For preparing the type prior to
executing the initializer, an TypeResolutionStrategy.Active
resolver must be chosen.
matcher
- The matcher that determines what methods or constructors are affected by the subsequent specification.DynamicType.Builder.MethodDefinition.ImplementationDefinition<T> invokable(LatentMatcher<? super MethodDescription> matcher)
Matches a method or constructor that is already declared or inherited by the instrumented type. This gives
opportunity to change or to override that method's or constructor's implementation, default value, annotations
or custom attributes. It is also possible to make a method abstract. Using a latent matcher gives opportunity
to resolve an ElementMatcher
based on the instrumented type before applying the matcher.
When a type is redefined or rebased, any annotations that the method or constructor declared previously is preserved
as it is if Byte Buddy is configured to retain such annotations by
AnnotationRetention.ENABLED
. If any existing annotations should be
altered, annotation retention must be disabled.
If a method or constructor is already matched by a previously specified matcher, the new definition gets precedence over the previous definition, i.e. the previous definition is no longer applied.
Note that the specified definition does never apply for methods that are explicitly ignored.
Important: It is possible to instrument the dynamic type's initializer. Depending on the used TypeResolutionStrategy
,
the type initializer might be run before Byte Buddy could apply any LoadedTypeInitializer
s which are
responsible for preparing the instrumented type prior to the initializer's execution. For preparing the type prior to
executing the initializer, an TypeResolutionStrategy.Active
resolver must be chosen.
matcher
- The matcher that determines what declared methods or constructors are affected by the subsequent specification.DynamicType.Builder<T> withHashCodeEquals()
Object.hashCode()
and Object.equals(Object)
methods for the instrumented type if those
methods are not declared as final
by a super class. The implementations do not consider any implementations
of a super class and compare a class field by field without considering synthetic fields.Object.hashCode()
and Object.equals(Object)
methods accordingly.DynamicType.Builder<T> withToString()
Object.toString()
method for the instrumented type if such a method is not declared as final
by a super class. The implementation prefixes the string with the simple class name and prints each non-synthetic field's
value after the field's name.Object.toString()
method accordingly.DynamicType.Builder.RecordComponentDefinition.Optional<T> defineRecordComponent(String name, Type type)
ByteBuddy.makeRecord()
is used.name
- The record component's name.type
- The record component's type.DynamicType.Builder.RecordComponentDefinition.Optional<T> defineRecordComponent(String name, TypeDefinition type)
ByteBuddy.makeRecord()
is used.name
- The record component's name.type
- The record component's type.DynamicType.Builder.RecordComponentDefinition.Optional<T> define(RecordComponentDescription recordComponentDescription)
ByteBuddy.makeRecord()
is used.recordComponentDescription
- A description of the record component to immitate.DynamicType.Builder.RecordComponentDefinition<T> recordComponent(ElementMatcher<? super RecordComponentDescription> matcher)
Matches a record component that is already declared by the instrumented type. This gives opportunity to change that record component's annotations or custom attributes.
When a type is redefined or rebased, any annotations that the field declared previously is preserved
as it is if Byte Buddy is configured to retain such annotations by
AnnotationRetention.ENABLED
. If any existing annotations should be
altered, annotation retention must be disabled.
If a record component is already matched by a previously specified record component matcher, the new record component definition gets precedence over the previous definition, i.e. the previous record component definition is no longer applied.
matcher
- The matcher that determines what declared record components are affected by the subsequent specification.DynamicType.Builder.RecordComponentDefinition<T> recordComponent(LatentMatcher<? super RecordComponentDescription> matcher)
Matches a record component that is already declared by the instrumented type. This gives opportunity to change that record component's annotations or custom attributes.
When a type is redefined or rebased, any annotations that the field declared previously is preserved
as it is if Byte Buddy is configured to retain such annotations by
AnnotationRetention.ENABLED
. If any existing annotations should be
altered, annotation retention must be disabled.
If a record component is already matched by a previously specified record component matcher, the new record component definition gets precedence over the previous definition, i.e. the previous record component definition is no longer applied.
matcher
- The matcher that determines what declared record components are affected by the subsequent specification.ContextClassVisitor wrap(ClassVisitor classVisitor)
TypePool
. A wrapper might not apply all features that are normally applied by Byte
Buddy, if those features require control of the class loading life cycle. Neither does a wrapper define
auxiliary types. It is therefore recommended to use Implementation.Context.Disabled
.classVisitor
- The class visitor to wrap.ContextClassVisitor wrap(ClassVisitor classVisitor, int writerFlags, int readerFlags)
TypePool
. A wrapper might not apply all features that are normally applied by Byte
Buddy, if those features require control of the class loading life cycle. Neither does a wrapper define
auxiliary types. It is therefore recommended to use Implementation.Context.Disabled
.classVisitor
- The class visitor to wrap.writerFlags
- The ASM writer flags to apply.readerFlags
- The ASM reader flags to apply.ContextClassVisitor wrap(ClassVisitor classVisitor, TypePool typePool)
Implementation.Context.Disabled
.classVisitor
- The class visitor to wrap.typePool
- A type pool that is used for computing stack map frames by the underlying class writer, if required.ContextClassVisitor wrap(ClassVisitor classVisitor, TypePool typePool, int writerFlags, int readerFlags)
Implementation.Context.Disabled
.classVisitor
- The class visitor to wrap.typePool
- A type pool that is used for computing stack map frames by the underlying class writer, if required.writerFlags
- The ASM writer flags to apply.readerFlags
- The ASM reader flags to apply.DynamicType.Unloaded<T> make()
Creates the dynamic type this builder represents. If the specified dynamic type is not legal, an IllegalStateException
is thrown.
Other than make(TypePool)
, this method supplies a context-dependant type pool to the underlying class writer.
Supplying a type pool only makes sense if custom byte code is created by adding a custom AsmVisitorWrapper
where ASM might be
required to compute stack map frames by processing information over any mentioned type's class hierarchy.
The dynamic type is initialized using a TypeResolutionStrategy.Passive
strategy. Using this strategy, no
LoadedTypeInitializer
is run during the execution of the type's initializer such that no Implementation
used for
executing the initializer must rely on such an initializer.
DynamicType.Unloaded<T> make(TypeResolutionStrategy typeResolutionStrategy)
Creates the dynamic type this builder represents. If the specified dynamic type is not legal, an IllegalStateException
is thrown.
The dynamic type is initialized using a TypeResolutionStrategy.Passive
strategy. Using this strategy, no
LoadedTypeInitializer
is run during the execution of the type's initializer such that no Implementation
used for
executing the initializer must rely on such an initializer.
typeResolutionStrategy
- The type resolution strategy to use for the created type's initialization.DynamicType.Unloaded<T> make(TypePool typePool)
Creates the dynamic type this builder represents. If the specified dynamic type is not legal, an IllegalStateException
is thrown.
The dynamic type is initialized using a TypeResolutionStrategy.Passive
strategy. Using this strategy, no
LoadedTypeInitializer
is run during the execution of the type's initializer such that no Implementation
used for
executing the initializer must rely on such an initializer.
typePool
- A type pool that is used for computing stack map frames by the underlying class writer, if required.DynamicType.Unloaded<T> make(TypeResolutionStrategy typeResolutionStrategy, TypePool typePool)
IllegalStateException
is thrown.typeResolutionStrategy
- The type resolution strategy to use for the created type's initialization.typePool
- A type pool that is used for computing stack map frames by the underlying class writer, if required.TypeDescription toTypeDescription()
TypeDescription
for the currently built type.TypeDescription
for the currently built type.Copyright © 2014–2024. All rights reserved.