Class DynamicType.Builder.AbstractBase<S>
- java.lang.Object
-
- net.bytebuddy.dynamic.DynamicType.Builder.AbstractBase<S>
-
- Type Parameters:
S
- A loaded type that the built type is guaranteed to be a subclass of.
- All Implemented Interfaces:
DynamicType.Builder<S>
- Direct Known Subclasses:
DecoratingDynamicTypeBuilder
,DynamicType.Builder.AbstractBase.Adapter
,DynamicType.Builder.AbstractBase.Delegator
- Enclosing interface:
- DynamicType.Builder<T>
public abstract static class DynamicType.Builder.AbstractBase<S> extends java.lang.Object implements DynamicType.Builder<S>
An abstract base implementation of a dynamic type builder.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DynamicType.Builder.AbstractBase.Adapter<U>
An adapter implementation of a dynamic type builder.static class
DynamicType.Builder.AbstractBase.Delegator<U>
A delegator for a dynamic type builder delegating all invocations to another dynamic type builder.-
Nested classes/interfaces inherited from interface net.bytebuddy.dynamic.DynamicType.Builder
DynamicType.Builder.AbstractBase<S>, DynamicType.Builder.FieldDefinition<S>, DynamicType.Builder.InnerTypeDefinition<S>, DynamicType.Builder.MethodDefinition<S>, DynamicType.Builder.RecordComponentDefinition<S>, DynamicType.Builder.TypeVariableDefinition<S>
-
-
Constructor Summary
Constructors Constructor Description AbstractBase()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DynamicType.Builder<S>
annotateType(java.lang.annotation.Annotation... annotation)
Annotates the instrumented type with the supplied annotations.DynamicType.Builder<S>
annotateType(java.util.List<? extends java.lang.annotation.Annotation> annotations)
Annotates the instrumented type with the supplied annotations.DynamicType.Builder<S>
annotateType(AnnotationDescription... annotation)
Annotates the instrumented type with the supplied annotations.DynamicType.Builder.MethodDefinition.ImplementationDefinition<S>
constructor(ElementMatcher<? super MethodDescription> matcher)
Matches a constructor that is already declared by the instrumented type.DynamicType.Builder<S>
declaredTypes(java.lang.Class<?>... type)
Defines this type as an the outer type of the supplied types.DynamicType.Builder<S>
declaredTypes(java.util.List<? extends java.lang.Class<?>> type)
Defines this type as an the outer type of the supplied types.DynamicType.Builder<S>
declaredTypes(TypeDescription... type)
Defines this type as an the outer type of the supplied types.DynamicType.Builder.MethodDefinition.ImplementationDefinition<S>
define(java.lang.reflect.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<S>
define(java.lang.reflect.Field field)
Defines a field that is similar to the supplied field but without copying any annotations on the field.DynamicType.Builder.MethodDefinition.ImplementationDefinition<S>
define(java.lang.reflect.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.FieldDefinition.Optional.Valuable<S>
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<S>
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<S>
define(RecordComponentDescription recordComponentDescription)
Defines a new record component.DynamicType.Builder.MethodDefinition.ParameterDefinition.Initial<S>
defineConstructor(java.util.Collection<? extends ModifierContributor.ForMethod> modifierContributors)
Defines the specified constructor to be declared by the instrumented type.DynamicType.Builder.MethodDefinition.ParameterDefinition.Initial<S>
defineConstructor(ModifierContributor.ForMethod... modifierContributor)
Defines the specified constructor to be declared by the instrumented type.DynamicType.Builder.FieldDefinition.Optional.Valuable<S>
defineField(java.lang.String name, java.lang.reflect.Type type, int modifiers)
Defines the specified field as a field of the built dynamic type.DynamicType.Builder.FieldDefinition.Optional.Valuable<S>
defineField(java.lang.String name, java.lang.reflect.Type type, java.util.Collection<? extends ModifierContributor.ForField> modifierContributors)
Defines the specified field as a field of the built dynamic type.DynamicType.Builder.FieldDefinition.Optional.Valuable<S>
defineField(java.lang.String name, java.lang.reflect.Type type, ModifierContributor.ForField... modifierContributor)
Defines the specified field as a field of the built dynamic type.DynamicType.Builder.FieldDefinition.Optional.Valuable<S>
defineField(java.lang.String name, TypeDefinition type, java.util.Collection<? extends ModifierContributor.ForField> modifierContributors)
Defines the specified field as a field of the built dynamic type.DynamicType.Builder.FieldDefinition.Optional.Valuable<S>
defineField(java.lang.String name, TypeDefinition type, ModifierContributor.ForField... modifierContributor)
Defines the specified field as a field of the built dynamic type.DynamicType.Builder.MethodDefinition.ParameterDefinition.Initial<S>
defineMethod(java.lang.String name, java.lang.reflect.Type returnType, int modifiers)
Defines the specified method to be declared by the instrumented type.DynamicType.Builder.MethodDefinition.ParameterDefinition.Initial<S>
defineMethod(java.lang.String name, java.lang.reflect.Type returnType, java.util.Collection<? extends ModifierContributor.ForMethod> modifierContributors)
Defines the specified method to be declared by the instrumented type.DynamicType.Builder.MethodDefinition.ParameterDefinition.Initial<S>
defineMethod(java.lang.String name, java.lang.reflect.Type returnType, ModifierContributor.ForMethod... modifierContributor)
Defines the specified method to be declared by the instrumented type.DynamicType.Builder.MethodDefinition.ParameterDefinition.Initial<S>
defineMethod(java.lang.String name, TypeDefinition returnType, java.util.Collection<? extends ModifierContributor.ForMethod> modifierContributors)
Defines the specified method to be declared by the instrumented type.DynamicType.Builder.MethodDefinition.ParameterDefinition.Initial<S>
defineMethod(java.lang.String name, TypeDefinition returnType, ModifierContributor.ForMethod... modifierContributor)
Defines the specified method to be declared by the instrumented type.DynamicType.Builder.FieldDefinition.Optional<S>
defineProperty(java.lang.String name, java.lang.reflect.Type type)
Defines a Java bean property with the specified name.DynamicType.Builder.FieldDefinition.Optional<S>
defineProperty(java.lang.String name, java.lang.reflect.Type type, boolean readOnly)
Defines a Java bean property with the specified name.DynamicType.Builder.FieldDefinition.Optional<S>
defineProperty(java.lang.String name, TypeDefinition type)
Defines a Java bean property with the specified name.DynamicType.Builder.FieldDefinition.Optional<S>
defineProperty(java.lang.String name, TypeDefinition type, boolean readOnly)
Defines a Java bean property with the specified name.DynamicType.Builder.RecordComponentDefinition.Optional<S>
defineRecordComponent(java.lang.String name, java.lang.reflect.Type type)
Defines a new record component.DynamicType.Builder.FieldDefinition.Valuable<S>
field(ElementMatcher<? super FieldDescription> matcher)
Matches a field that is already declared by the instrumented type.DynamicType.Builder<S>
ignoreAlso(ElementMatcher<? super MethodDescription> ignoredMethods)
Specifies to exclude any method that is matched by the supplied matcher from instrumentation.DynamicType.Builder.MethodDefinition.ImplementationDefinition.Optional<S>
implement(java.lang.reflect.Type... interfaceType)
Implements the supplied interfaces for the instrumented type.DynamicType.Builder.MethodDefinition.ImplementationDefinition.Optional<S>
implement(java.util.List<? extends java.lang.reflect.Type> interfaceTypes)
Implements the supplied interfaces for the instrumented type.DynamicType.Builder.MethodDefinition.ImplementationDefinition.Optional<S>
implement(TypeDefinition... interfaceType)
Implements the supplied interfaces for the instrumented type.DynamicType.Builder.InnerTypeDefinition.ForType<S>
innerTypeOf(java.lang.Class<?> type)
Defines this type as an inner type of the supplied type.DynamicType.Builder.InnerTypeDefinition<S>
innerTypeOf(java.lang.reflect.Constructor<?> constructor)
Defines this type as an inner type that was declared within the supplied constructor.DynamicType.Builder.InnerTypeDefinition<S>
innerTypeOf(java.lang.reflect.Method method)
Defines this type as an inner type that was declared within the supplied method.DynamicType.Builder.MethodDefinition.ImplementationDefinition<S>
invokable(ElementMatcher<? super MethodDescription> matcher)
Matches a method or constructor that is already declared or inherited by the instrumented type.DynamicType.Unloaded<S>
make()
Creates the dynamic type this builder represents.DynamicType.Unloaded<S>
make(TypePool typePool)
Creates the dynamic type this builder represents.DynamicType.Builder<S>
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<S>
method(ElementMatcher<? super MethodDescription> matcher)
Matches a method that is already declared or inherited by the instrumented type.DynamicType.Builder<S>
modifiers(java.util.Collection<? extends ModifierContributor.ForType> modifierContributors)
Defines the supplied modifiers as the modifiers of the instrumented type.DynamicType.Builder<S>
modifiers(ModifierContributor.ForType... modifierContributor)
Defines the supplied modifiers as the modifiers of the instrumented type.DynamicType.Builder<S>
nestHost(java.lang.Class<?> type)
Defines this type as a nest member of the supplied type as a nest host.DynamicType.Builder<S>
nestMembers(java.lang.Class<?>... type)
Defines this type as a nest host for the supplied types.DynamicType.Builder<S>
nestMembers(java.util.List<? extends java.lang.Class<?>> types)
Defines this type as a nest host for the supplied types.DynamicType.Builder<S>
nestMembers(TypeDescription... type)
Defines this type as a nest host for the supplied types.DynamicType.Builder<S>
noNestMate()
Defines this type as self-hosted, i.e.DynamicType.Builder<S>
permittedSubclass(java.lang.Class<?>... type)
Defines this type to allow the supplied permitted subclasses additionally to any prior permitted subclasses.DynamicType.Builder<S>
permittedSubclass(java.util.List<? extends java.lang.Class<?>> types)
Defines this type to allow the supplied permitted subclasses additionally to any prior permitted subclasses.DynamicType.Builder<S>
permittedSubclass(TypeDescription... type)
Defines this type to allow the supplied permitted subclasses additionally to any prior permitted subclasses.DynamicType.Builder.RecordComponentDefinition<S>
recordComponent(ElementMatcher<? super RecordComponentDescription> matcher)
Matches a record component that is already declared by the instrumented type.DynamicType.Builder<S>
require(TypeDescription type, byte[] binaryRepresentation)
Explicitly requires another dynamic type for the creation of this type.DynamicType.Builder<S>
require(TypeDescription type, byte[] binaryRepresentation, LoadedTypeInitializer typeInitializer)
Explicitly requires another dynamic type for the creation of this type.DynamicType.Builder<S>
require(DynamicType... auxiliaryType)
Explicitly requires other dynamic types for the creation of this type.DynamicType.Builder.FieldDefinition.Optional<S>
serialVersionUid(long serialVersionUid)
Defines a private, static, final field for a serial version UID of the given value.DynamicType.Builder.TypeVariableDefinition<S>
typeVariable(java.lang.String symbol)
Defines the supplied type variable without any bounds as a type variable of the instrumented type.DynamicType.Builder.TypeVariableDefinition<S>
typeVariable(java.lang.String symbol, java.lang.reflect.Type... bound)
Defines the supplied type variable with the given bound as a type variable of the instrumented type.DynamicType.Builder.TypeVariableDefinition<S>
typeVariable(java.lang.String symbol, java.util.List<? extends java.lang.reflect.Type> bounds)
Defines the supplied type variable with the given bound as a type variable of the instrumented type.DynamicType.Builder.TypeVariableDefinition<S>
typeVariable(java.lang.String symbol, TypeDefinition... bound)
Defines the supplied type variable with the given bound as a type variable of the instrumented type.DynamicType.Builder<S>
withHashCodeEquals()
ImplementsObject.hashCode()
andObject.equals(Object)
methods for the instrumented type if those methods are not declared asfinal
by a super class.DynamicType.Builder<S>
withToString()
Implements aObject.toString()
method for the instrumented type if such a method is not declared asfinal
by a super class.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.bytebuddy.dynamic.DynamicType.Builder
annotateType, attribute, declaredTypes, defineConstructor, defineField, defineMethod, defineRecordComponent, field, ignoreAlso, implement, initializer, initializer, innerTypeOf, innerTypeOf, invokable, make, make, merge, modifiers, name, nestHost, nestMembers, permittedSubclass, recordComponent, require, suffix, topLevelType, toTypeDescription, transform, typeVariable, unsealed, visit
-
-
-
-
Method Detail
-
innerTypeOf
public DynamicType.Builder.InnerTypeDefinition.ForType<S> innerTypeOf(java.lang.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.
- Specified by:
innerTypeOf
in interfaceDynamicType.Builder<S>
- Parameters:
type
- The type to declare as the built type's outer type.- Returns:
- A new builder that is equal to this builder with the supplied type as the built type's outer type.
-
innerTypeOf
public DynamicType.Builder.InnerTypeDefinition<S> innerTypeOf(java.lang.reflect.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.
- Specified by:
innerTypeOf
in interfaceDynamicType.Builder<S>
- Parameters:
method
- The method to declare as the built type's declaring method.- Returns:
- A new builder that is equal to this builder with the supplied method as the built type's declaring method.
-
innerTypeOf
public DynamicType.Builder.InnerTypeDefinition<S> innerTypeOf(java.lang.reflect.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.
- Specified by:
innerTypeOf
in interfaceDynamicType.Builder<S>
- Parameters:
constructor
- The constructor to declare as the built type's declaring method.- Returns:
- A new builder that is equal to this builder with the supplied method as the built type's declaring constructor.
-
declaredTypes
public DynamicType.Builder<S> declaredTypes(java.lang.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.
- Specified by:
declaredTypes
in interfaceDynamicType.Builder<S>
- Parameters:
type
- The types being declared.- Returns:
- A new builder that is equal to this builder with the supplied types being declared by the built type.
-
declaredTypes
public DynamicType.Builder<S> 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.
- Specified by:
declaredTypes
in interfaceDynamicType.Builder<S>
- Parameters:
type
- The types being declared.- Returns:
- A new builder that is equal to this builder with the supplied types being declared by the built type.
-
declaredTypes
public DynamicType.Builder<S> declaredTypes(java.util.List<? extends java.lang.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.
- Specified by:
declaredTypes
in interfaceDynamicType.Builder<S>
- Parameters:
type
- The types being declared.- Returns:
- A new builder that is equal to this builder with the supplied types being declared by the built type.
-
noNestMate
public DynamicType.Builder<S> 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.
- Specified by:
noNestMate
in interfaceDynamicType.Builder<S>
- Returns:
- A new builder that is equal to this builder but where the built type is a self-hosted nest mate.
-
nestHost
public DynamicType.Builder<S> nestHost(java.lang.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.
- Specified by:
nestHost
in interfaceDynamicType.Builder<S>
- Parameters:
type
- The nest host.- Returns:
- A new builder that is equal to this builder but where the built type is a nest member of the supplied host.
-
nestMembers
public DynamicType.Builder<S> nestMembers(java.lang.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.
- Specified by:
nestMembers
in interfaceDynamicType.Builder<S>
- Parameters:
type
- The nest members.- Returns:
- A new builder that is equal to this builder but where the built type is a nest host of the supplied types.
-
nestMembers
public DynamicType.Builder<S> 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.
- Specified by:
nestMembers
in interfaceDynamicType.Builder<S>
- Parameters:
type
- The nest members.- Returns:
- A new builder that is equal to this builder but where the built type is a nest host of the supplied types.
-
nestMembers
public DynamicType.Builder<S> nestMembers(java.util.List<? extends java.lang.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.
- Specified by:
nestMembers
in interfaceDynamicType.Builder<S>
- Parameters:
types
- The nest members.- Returns:
- A new builder that is equal to this builder but where the built type is a nest host of the supplied types.
-
permittedSubclass
public DynamicType.Builder<S> permittedSubclass(java.lang.Class<?>... type)
Defines this type to allow the supplied permitted subclasses additionally to any prior permitted subclasses. If this type was not previously sealed, only the supplied subclasses are permitted.- Specified by:
permittedSubclass
in interfaceDynamicType.Builder<S>
- Parameters:
type
- The permitted subclasses.- Returns:
- A new builder that is equal to this builder but where the built type permits the supplied subclasses.
-
permittedSubclass
public DynamicType.Builder<S> permittedSubclass(TypeDescription... type)
Defines this type to allow the supplied permitted subclasses additionally to any prior permitted subclasses. If this type was not previously sealed, only the supplied subclasses are permitted.- Specified by:
permittedSubclass
in interfaceDynamicType.Builder<S>
- Parameters:
type
- The permitted subclasses.- Returns:
- A new builder that is equal to this builder but where the built type permits the supplied subclasses.
-
permittedSubclass
public DynamicType.Builder<S> permittedSubclass(java.util.List<? extends java.lang.Class<?>> types)
Defines this type to allow the supplied permitted subclasses additionally to any prior permitted subclasses. If this type was not previously sealed, only the supplied subclasses are permitted.- Specified by:
permittedSubclass
in interfaceDynamicType.Builder<S>
- Parameters:
types
- The permitted subclasses.- Returns:
- A new builder that is equal to this builder but where the built type permits the supplied subclasses.
-
annotateType
public DynamicType.Builder<S> annotateType(java.lang.annotation.Annotation... annotation)
Annotates the instrumented type with the supplied annotations.- Specified by:
annotateType
in interfaceDynamicType.Builder<S>
- Parameters:
annotation
- The annotations to add to the instrumented type.- Returns:
- A new builder that is equal to this builder but with the annotations added to the instrumented type.
-
annotateType
public DynamicType.Builder<S> annotateType(java.util.List<? extends java.lang.annotation.Annotation> annotations)
Annotates the instrumented type with the supplied annotations.- Specified by:
annotateType
in interfaceDynamicType.Builder<S>
- Parameters:
annotations
- The annotations to add to the instrumented type.- Returns:
- A new builder that is equal to this builder but with the annotations added to the instrumented type.
-
annotateType
public DynamicType.Builder<S> annotateType(AnnotationDescription... annotation)
Annotates the instrumented type with the supplied annotations.- Specified by:
annotateType
in interfaceDynamicType.Builder<S>
- Parameters:
annotation
- The annotations to add to the instrumented type.- Returns:
- A new builder that is equal to this builder but with the annotations added to the instrumented type.
-
modifiers
public DynamicType.Builder<S> modifiers(ModifierContributor.ForType... modifierContributor)
Defines the supplied modifiers as the modifiers of the instrumented type.- Specified by:
modifiers
in interfaceDynamicType.Builder<S>
- Parameters:
modifierContributor
- The modifiers of the instrumented type.- Returns:
- A new builder that is equal to this builder but with the supplied modifiers applied onto the instrumented type.
-
modifiers
public DynamicType.Builder<S> modifiers(java.util.Collection<? extends ModifierContributor.ForType> modifierContributors)
Defines the supplied modifiers as the modifiers of the instrumented type.- Specified by:
modifiers
in interfaceDynamicType.Builder<S>
- Parameters:
modifierContributors
- The modifiers of the instrumented type.- Returns:
- A new builder that is equal to this builder but with the supplied modifiers applied onto the instrumented type.
-
merge
public DynamicType.Builder<S> 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.- Specified by:
merge
in interfaceDynamicType.Builder<S>
- Parameters:
modifierContributor
- The modifiers of the instrumented type.- Returns:
- A new builder that is equal to this builder but with the supplied modifiers merged into the instrumented type's modifiers.
-
implement
public DynamicType.Builder.MethodDefinition.ImplementationDefinition.Optional<S> implement(java.lang.reflect.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.- Specified by:
implement
in interfaceDynamicType.Builder<S>
- Parameters:
interfaceType
- The interface types to implement.- Returns:
- A new builder that is equal to this builder but with the interfaces implemented by the instrumented type.
-
implement
public DynamicType.Builder.MethodDefinition.ImplementationDefinition.Optional<S> implement(java.util.List<? extends java.lang.reflect.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.- Specified by:
implement
in interfaceDynamicType.Builder<S>
- Parameters:
interfaceTypes
- The interface types to implement.- Returns:
- A new builder that is equal to this builder but with the interfaces implemented by the instrumented type.
-
implement
public DynamicType.Builder.MethodDefinition.ImplementationDefinition.Optional<S> 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.- Specified by:
implement
in interfaceDynamicType.Builder<S>
- Parameters:
interfaceType
- The interface types to implement.- Returns:
- A new builder that is equal to this builder but with the interfaces implemented by the instrumented type.
-
typeVariable
public DynamicType.Builder.TypeVariableDefinition<S> typeVariable(java.lang.String symbol)
Defines the supplied type variable without any bounds as a type variable of the instrumented type.- Specified by:
typeVariable
in interfaceDynamicType.Builder<S>
- Parameters:
symbol
- The type variable's symbol.- Returns:
- A new builder that is equal to this builder but with the given type variable defined for the instrumented type.
-
typeVariable
public DynamicType.Builder.TypeVariableDefinition<S> typeVariable(java.lang.String symbol, java.lang.reflect.Type... bound)
Defines the supplied type variable with the given bound as a type variable of the instrumented type.- Specified by:
typeVariable
in interfaceDynamicType.Builder<S>
- Parameters:
symbol
- The type variable's symbol.bound
- The type variable's upper bounds. Can also beTargetType
if the bound type should be equal to the currently instrumented type.- Returns:
- A new builder that is equal to this builder but with the given type variable defined for the instrumented type.
-
typeVariable
public DynamicType.Builder.TypeVariableDefinition<S> typeVariable(java.lang.String symbol, java.util.List<? extends java.lang.reflect.Type> bounds)
Defines the supplied type variable with the given bound as a type variable of the instrumented type.- Specified by:
typeVariable
in interfaceDynamicType.Builder<S>
- Parameters:
symbol
- The type variable's symbol.bounds
- The type variable's upper bounds. Can also beTargetType
if the bound type should be equal to the currently instrumented type.- Returns:
- A new builder that is equal to this builder but with the given type variable defined for the instrumented type.
-
typeVariable
public DynamicType.Builder.TypeVariableDefinition<S> typeVariable(java.lang.String symbol, TypeDefinition... bound)
Defines the supplied type variable with the given bound as a type variable of the instrumented type.- Specified by:
typeVariable
in interfaceDynamicType.Builder<S>
- Parameters:
symbol
- The type variable's symbol.bound
- The type variable's upper bounds. Can also beTargetType
if the bound type should be equal to the currently instrumented type.- Returns:
- A new builder that is equal to this builder but with the given type variable defined for the instrumented type.
-
defineRecordComponent
public DynamicType.Builder.RecordComponentDefinition.Optional<S> defineRecordComponent(java.lang.String name, java.lang.reflect.Type type)
Defines a new record component. Note that this does not add or change implementations for a field, an accessor to this field or a constructor unlessByteBuddy.makeRecord()
is used.- Specified by:
defineRecordComponent
in interfaceDynamicType.Builder<S>
- Parameters:
name
- The record component's name.type
- The record component's type.- Returns:
- A new builder that is equal to this builder but also defines the supplied record component.
-
define
public DynamicType.Builder.RecordComponentDefinition.Optional<S> define(RecordComponentDescription recordComponentDescription)
Defines a new record component. Note that this does not add or change implementations for a field, an accessor to this field or a constructor unlessByteBuddy.makeRecord()
is used.- Specified by:
define
in interfaceDynamicType.Builder<S>
- Parameters:
recordComponentDescription
- A description of the record component to immitate.- Returns:
- A new builder that is equal to this builder but also defines the supplied record component.
-
recordComponent
public DynamicType.Builder.RecordComponentDefinition<S> 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.
- Specified by:
recordComponent
in interfaceDynamicType.Builder<S>
- Parameters:
matcher
- The matcher that determines what declared record components are affected by the subsequent specification.- Returns:
- A builder that allows for changing a record component's definition.
-
defineField
public DynamicType.Builder.FieldDefinition.Optional.Valuable<S> defineField(java.lang.String name, java.lang.reflect.Type type, ModifierContributor.ForField... modifierContributor)
Defines the specified field as a field of the built dynamic type.- Specified by:
defineField
in interfaceDynamicType.Builder<S>
- Parameters:
name
- The name of the field.type
- The type of the field. Can also beTargetType
if the field type should be equal to the currently instrumented type.modifierContributor
- The modifiers of the field.- Returns:
- A new builder that is equal to this builder but with the given field defined for the instrumented type. Furthermore, it is possible to optionally define a value, annotations or custom attributes for the field.
-
defineField
public DynamicType.Builder.FieldDefinition.Optional.Valuable<S> defineField(java.lang.String name, java.lang.reflect.Type type, java.util.Collection<? extends ModifierContributor.ForField> modifierContributors)
Defines the specified field as a field of the built dynamic type.- Specified by:
defineField
in interfaceDynamicType.Builder<S>
- Parameters:
name
- The name of the field.type
- The type of the field. Can also beTargetType
if the field type should be equal to the currently instrumented type.modifierContributors
- The modifiers of the field.- Returns:
- A new builder that is equal to this builder but with the given field defined for the instrumented type. Furthermore, it is possible to optionally define a value, annotations or custom attributes for the field.
-
defineField
public DynamicType.Builder.FieldDefinition.Optional.Valuable<S> defineField(java.lang.String name, java.lang.reflect.Type type, int modifiers)
Defines the specified field as a field of the built dynamic type.- Specified by:
defineField
in interfaceDynamicType.Builder<S>
- Parameters:
name
- The name of the field.type
- The type of the field. Can also beTargetType
if the field type should be equal to the currently instrumented type.modifiers
- The modifiers of the field.- Returns:
- A new builder that is equal to this builder but with the given field defined for the instrumented type. Furthermore, it is possible to optionally define a value, annotations or custom attributes for the field.
-
defineField
public DynamicType.Builder.FieldDefinition.Optional.Valuable<S> defineField(java.lang.String name, TypeDefinition type, ModifierContributor.ForField... modifierContributor)
Defines the specified field as a field of the built dynamic type.- Specified by:
defineField
in interfaceDynamicType.Builder<S>
- Parameters:
name
- The name of the field.type
- The type of the field. Can also beTargetType
if the field type should be equal to the currently instrumented type.modifierContributor
- The modifiers of the field.- Returns:
- A new builder that is equal to this builder but with the given field defined for the instrumented type. Furthermore, it is possible to optionally define a value, annotations or custom attributes for the field.
-
defineField
public DynamicType.Builder.FieldDefinition.Optional.Valuable<S> defineField(java.lang.String name, TypeDefinition type, java.util.Collection<? extends ModifierContributor.ForField> modifierContributors)
Defines the specified field as a field of the built dynamic type.- Specified by:
defineField
in interfaceDynamicType.Builder<S>
- Parameters:
name
- The name of the field.type
- The type of the field. Can also beTargetType
if the field type should be equal to the currently instrumented type.modifierContributors
- The modifiers of the field.- Returns:
- A new builder that is equal to this builder but with the given field defined for the instrumented type. Furthermore, it is possible to optionally define a value, annotations or custom attributes for the field.
-
define
public DynamicType.Builder.FieldDefinition.Optional.Valuable<S> define(java.lang.reflect.Field field)
Defines a field that is similar to the supplied field but without copying any annotations on the field.- Specified by:
define
in interfaceDynamicType.Builder<S>
- Parameters:
field
- The field to imitate as a field of the instrumented type.- Returns:
- A new builder that is equal to this builder but with the given field defined for the instrumented type. Furthermore, it is possible to optionally define a value, annotations or custom attributes for the field.
-
define
public DynamicType.Builder.FieldDefinition.Optional.Valuable<S> define(FieldDescription field)
Defines a field that is similar to the supplied field but without copying any annotations on the field.- Specified by:
define
in interfaceDynamicType.Builder<S>
- Parameters:
field
- The field to imitate as a field of the instrumented type.- Returns:
- A new builder that is equal to this builder but with the given field defined for the instrumented type. Furthermore, it is possible to optionally define a value, annotations or custom attributes for the field.
-
serialVersionUid
public DynamicType.Builder.FieldDefinition.Optional<S> serialVersionUid(long serialVersionUid)
Defines a private, static, final field for a serial version UID of the given value.- Specified by:
serialVersionUid
in interfaceDynamicType.Builder<S>
- Parameters:
serialVersionUid
- The serial version UID to define as a value.- Returns:
- A new builder that is equal to this builder but with the given type variable defined for the instrumented type. Furthermore, it is possible to optionally define a value, annotations or custom attributes for the field.
-
field
public DynamicType.Builder.FieldDefinition.Valuable<S> 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.
- Specified by:
field
in interfaceDynamicType.Builder<S>
- Parameters:
matcher
- The matcher that determines what declared fields are affected by the subsequent specification.- Returns:
- A builder that allows for changing a field's definition.
-
ignoreAlso
public DynamicType.Builder<S> 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.
- Specified by:
ignoreAlso
in interfaceDynamicType.Builder<S>
- Parameters:
ignoredMethods
- The matcher for determining what methods to exclude from instrumentation.- Returns:
- A new builder that is equal to this builder but that is excluding any method that is matched by the supplied matcher from instrumentation.
-
defineMethod
public DynamicType.Builder.MethodDefinition.ParameterDefinition.Initial<S> defineMethod(java.lang.String name, java.lang.reflect.Type returnType, ModifierContributor.ForMethod... modifierContributor)
Defines the specified method to be declared by the instrumented type. Method parameters or parameter types, declared exceptions and type variables can be defined in subsequent steps.- Specified by:
defineMethod
in interfaceDynamicType.Builder<S>
- Parameters:
name
- The name of the method.returnType
- The method's return type. Can also beTargetType
if the return type should be equal to the currently instrumented type.modifierContributor
- The method's modifiers.- Returns:
- A builder that allows for further defining the method, either by adding more properties or by defining an implementation.
-
defineMethod
public DynamicType.Builder.MethodDefinition.ParameterDefinition.Initial<S> defineMethod(java.lang.String name, java.lang.reflect.Type returnType, java.util.Collection<? extends ModifierContributor.ForMethod> modifierContributors)
Defines the specified method to be declared by the instrumented type. Method parameters or parameter types, declared exceptions and type variables can be defined in subsequent steps.- Specified by:
defineMethod
in interfaceDynamicType.Builder<S>
- Parameters:
name
- The name of the method.returnType
- The method's return type. Can also beTargetType
if the return type should be equal to the currently instrumented type.modifierContributors
- The method's modifiers.- Returns:
- A builder that allows for further defining the method, either by adding more properties or by defining an implementation.
-
defineMethod
public DynamicType.Builder.MethodDefinition.ParameterDefinition.Initial<S> defineMethod(java.lang.String name, java.lang.reflect.Type returnType, int modifiers)
Defines the specified method to be declared by the instrumented type. Method parameters or parameter types, declared exceptions and type variables can be defined in subsequent steps.- Specified by:
defineMethod
in interfaceDynamicType.Builder<S>
- Parameters:
name
- The name of the method.returnType
- The method's return type. Can also beTargetType
if the return type should be equal to the currently instrumented type.modifiers
- The method's modifiers.- Returns:
- A builder that allows for further defining the method, either by adding more properties or by defining an implementation.
-
defineMethod
public DynamicType.Builder.MethodDefinition.ParameterDefinition.Initial<S> defineMethod(java.lang.String name, TypeDefinition returnType, ModifierContributor.ForMethod... modifierContributor)
Defines the specified method to be declared by the instrumented type. Method parameters or parameter types, declared exceptions and type variables can be defined in subsequent steps.- Specified by:
defineMethod
in interfaceDynamicType.Builder<S>
- Parameters:
name
- The name of the method.returnType
- The method's return type. Can also beTargetType
if the return type should be equal to the currently instrumented type.modifierContributor
- The method's modifiers.- Returns:
- A builder that allows for further defining the method, either by adding more properties or by defining an implementation.
-
defineMethod
public DynamicType.Builder.MethodDefinition.ParameterDefinition.Initial<S> defineMethod(java.lang.String name, TypeDefinition returnType, java.util.Collection<? extends ModifierContributor.ForMethod> modifierContributors)
Defines the specified method to be declared by the instrumented type. Method parameters or parameter types, declared exceptions and type variables can be defined in subsequent steps.- Specified by:
defineMethod
in interfaceDynamicType.Builder<S>
- Parameters:
name
- The name of the method.returnType
- The method's return type. Can also beTargetType
if the return type should be equal to the currently instrumented type.modifierContributors
- The method's modifiers.- Returns:
- A builder that allows for further defining the method, either by adding more properties or by defining an implementation.
-
defineConstructor
public DynamicType.Builder.MethodDefinition.ParameterDefinition.Initial<S> defineConstructor(ModifierContributor.ForMethod... modifierContributor)
Defines the specified constructor to be declared by the instrumented type. Method parameters or parameter types, declared exceptions and type variables can be defined in subsequent steps.- Specified by:
defineConstructor
in interfaceDynamicType.Builder<S>
- Parameters:
modifierContributor
- The constructor's modifiers.- Returns:
- A builder that allows for further defining the constructor, either by adding more properties or by defining an implementation.
-
defineConstructor
public DynamicType.Builder.MethodDefinition.ParameterDefinition.Initial<S> defineConstructor(java.util.Collection<? extends ModifierContributor.ForMethod> modifierContributors)
Defines the specified constructor to be declared by the instrumented type. Method parameters or parameter types, declared exceptions and type variables can be defined in subsequent steps.- Specified by:
defineConstructor
in interfaceDynamicType.Builder<S>
- Parameters:
modifierContributors
- The constructor's modifiers.- Returns:
- A builder that allows for further defining the constructor, either by adding more properties or by defining an implementation.
-
define
public DynamicType.Builder.MethodDefinition.ImplementationDefinition<S> define(java.lang.reflect.Method method)
Defines a method that is similar to the supplied method but without copying any annotations of the method or method parameters.- Specified by:
define
in interfaceDynamicType.Builder<S>
- Parameters:
method
- The method to imitate as a method of the instrumented type.- Returns:
- A builder that allows for defining an implementation for the method.
-
define
public DynamicType.Builder.MethodDefinition.ImplementationDefinition<S> define(java.lang.reflect.Constructor<?> constructor)
Defines a constructor that is similar to the supplied constructor but without copying any annotations of the constructor or constructor parameters.- Specified by:
define
in interfaceDynamicType.Builder<S>
- Parameters:
constructor
- The constructor to imitate as a method of the instrumented type.- Returns:
- A builder that allows for defining an implementation for the constructor.
-
define
public DynamicType.Builder.MethodDefinition.ImplementationDefinition<S> 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.- Specified by:
define
in interfaceDynamicType.Builder<S>
- Parameters:
methodDescription
- The method description to imitate as a method or constructor of the instrumented type.- Returns:
- A builder that allows for defining an implementation for the method or constructor.
-
defineProperty
public DynamicType.Builder.FieldDefinition.Optional<S> defineProperty(java.lang.String name, java.lang.reflect.Type type)
Defines a Java bean property with the specified name.- Specified by:
defineProperty
in interfaceDynamicType.Builder<S>
- Parameters:
name
- The name of the property.type
- The property type.- Returns:
- A builder that defines the specified property where the field holding the property can be refined by subsequent steps.
-
defineProperty
public DynamicType.Builder.FieldDefinition.Optional<S> defineProperty(java.lang.String name, java.lang.reflect.Type type, boolean readOnly)
Defines a Java bean property with the specified name.- Specified by:
defineProperty
in interfaceDynamicType.Builder<S>
- Parameters:
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 befinal
.- Returns:
- A builder that defines the specified property where the field holding the property can be refined by subsequent steps.
-
defineProperty
public DynamicType.Builder.FieldDefinition.Optional<S> defineProperty(java.lang.String name, TypeDefinition type)
Defines a Java bean property with the specified name.- Specified by:
defineProperty
in interfaceDynamicType.Builder<S>
- Parameters:
name
- The name of the property.type
- The property type.- Returns:
- A builder that defines the specified property where the field holding the property can be refined by subsequent steps.
-
defineProperty
public DynamicType.Builder.FieldDefinition.Optional<S> defineProperty(java.lang.String name, TypeDefinition type, boolean readOnly)
Defines a Java bean property with the specified name.- Specified by:
defineProperty
in interfaceDynamicType.Builder<S>
- Parameters:
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 befinal
.- Returns:
- A builder that defines the specified property where the field holding the property can be refined by subsequent steps.
-
method
public DynamicType.Builder.MethodDefinition.ImplementationDefinition<S> 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.
- Specified by:
method
in interfaceDynamicType.Builder<S>
- Parameters:
matcher
- The matcher that determines what methods are affected by the subsequent specification.- Returns:
- A builder that allows for changing a method's or constructor's definition.
-
constructor
public DynamicType.Builder.MethodDefinition.ImplementationDefinition<S> 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.
- Specified by:
constructor
in interfaceDynamicType.Builder<S>
- Parameters:
matcher
- The matcher that determines what constructors are affected by the subsequent specification.- Returns:
- A builder that allows for changing a method's or constructor's definition.
-
invokable
public DynamicType.Builder.MethodDefinition.ImplementationDefinition<S> 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 anyLoadedTypeInitializer
s which are responsible for preparing the instrumented type prior to the initializer's execution. For preparing the type prior to executing the initializer, anTypeResolutionStrategy.Active
resolver must be chosen.- Specified by:
invokable
in interfaceDynamicType.Builder<S>
- Parameters:
matcher
- The matcher that determines what methods or constructors are affected by the subsequent specification.- Returns:
- A builder that allows for changing a method's or constructor's definition.
-
withHashCodeEquals
public DynamicType.Builder<S> withHashCodeEquals()
ImplementsObject.hashCode()
andObject.equals(Object)
methods for the instrumented type if those methods are not declared asfinal
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.- Specified by:
withHashCodeEquals
in interfaceDynamicType.Builder<S>
- Returns:
- A new type builder that defines
Object.hashCode()
andObject.equals(Object)
methods accordingly.
-
withToString
public DynamicType.Builder<S> withToString()
Implements aObject.toString()
method for the instrumented type if such a method is not declared asfinal
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.- Specified by:
withToString
in interfaceDynamicType.Builder<S>
- Returns:
- A new type builder that defines
Object.toString()
method accordingly.
-
require
public DynamicType.Builder<S> require(TypeDescription type, byte[] binaryRepresentation)
Explicitly requires another dynamic type for the creation of this type.- Specified by:
require
in interfaceDynamicType.Builder<S>
- Parameters:
type
- The type to require.binaryRepresentation
- The type's binary representation.- Returns:
- A new builder that is equal to this builder but which explicitly requires the supplied type.
-
require
public DynamicType.Builder<S> require(TypeDescription type, byte[] binaryRepresentation, LoadedTypeInitializer typeInitializer)
Explicitly requires another dynamic type for the creation of this type.- Specified by:
require
in interfaceDynamicType.Builder<S>
- Parameters:
type
- The type to require.binaryRepresentation
- The type's binary representation.typeInitializer
- The type's loaded type initializer.- Returns:
- A new builder that is equal to this builder but which explicitly requires the supplied type.
-
require
public DynamicType.Builder<S> require(DynamicType... auxiliaryType)
Explicitly requires other dynamic types for the creation of this type.- Specified by:
require
in interfaceDynamicType.Builder<S>
- Parameters:
auxiliaryType
- The required dynamic types.- Returns:
- A new builder that is equal to this builder but which explicitly requires the supplied types.
-
make
public DynamicType.Unloaded<S> 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, noLoadedTypeInitializer
is run during the execution of the type's initializer such that noImplementation
used for executing the initializer must rely on such an initializer.- Specified by:
make
in interfaceDynamicType.Builder<S>
- Parameters:
typePool
- A type pool that is used for computing stack map frames by the underlying class writer, if required.- Returns:
- An unloaded dynamic type representing the type specified by this builder.
-
make
public DynamicType.Unloaded<S> make()
Creates the dynamic type this builder represents. If the specified dynamic type is not legal, an
IllegalStateException
is thrown.Other than
DynamicType.Builder.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 customAsmVisitorWrapper
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, noLoadedTypeInitializer
is run during the execution of the type's initializer such that noImplementation
used for executing the initializer must rely on such an initializer.- Specified by:
make
in interfaceDynamicType.Builder<S>
- Returns:
- An unloaded dynamic type representing the type specified by this builder.
-
-