net.bytebuddy.dynamic.DynamicType.Builder
interface. Byte Buddy's API is expressed by fully immutable
components and is therefore thread-safe. As a consequence, method calls must be chained for all of Byte Buddy's
component, e.g. a method call like the following has no effect:
ByteBuddy byteBuddy = new ByteBuddy(); byteBuddy.foo()Instead, the following method chain is correct use of the API:
ByteBuddy byteBuddy = new ByteBuddy().foo();
For the creation of Java agents, Byte Buddy offers a convenience API implemented by the
net.
. The API wraps a ByteBuddy
instance and offers agent-specific
configuration opportunities by integrating against the java.
API.
net.bytebuddy.agent.builder.AgentBuilder
Modifier and Type | Class and Description |
---|---|
protected static class | ByteBuddy.EnumerationImplementation
An implementation fo the |
protected static enum | ByteBuddy.RecordConstructorStrategy
A constructor strategy for implementing a Java record. |
protected static enum | ByteBuddy.RecordObjectMethod
Implements the object methods of the Java record type. |
Modifier and Type | Field and Description |
---|---|
protected final AnnotationRetention | annotationRetention
The annotation retention strategy to use. |
protected final AnnotationValueFilter. | annotationValueFilterFactory
The annotation value filter factory to use. |
protected final AuxiliaryType. | auxiliaryTypeNamingStrategy
The naming strategy to use for naming auxiliary types. |
private static final String | BYTE_BUDDY_DEFAULT_CONTEXT_NAME
The default name of a fixed context name for synthetic fields and methods. |
private static final String | BYTE_BUDDY_DEFAULT_PREFIX
The default prefix for the default |
private static final String | BYTE_BUDDY_DEFAULT_SUFFIX
The default suffix when defining a |
protected final ClassFileVersion | classFileVersion
The class file version to use for types that are not based on an existing class file. |
protected final ClassWriterStrategy | classWriterStrategy
The class writer strategy to use. |
private static final AuxiliaryType. | DEFAULT_AUXILIARY_NAMING_STRATEGY
The default auxiliary naming strategy or |
private static final Implementation. | DEFAULT_IMPLEMENTATION_CONTEXT_FACTORY
The default implementation context factory or |
public static final String | DEFAULT_NAMING_PROPERTY
A property that controls the default naming strategy. |
private static final NamingStrategy | DEFAULT_NAMING_STRATEGY
The default naming strategy or |
protected final LatentMatcher | ignoredMethods
A matcher for identifying methods that should be excluded from instrumentation. |
protected final Implementation. | implementationContextFactory
The implementation context factory to use. |
protected final InstrumentedType. | instrumentedTypeFactory
The instrumented type factory to use. |
protected final MethodGraph. | methodGraphCompiler
The method graph compiler to use. |
protected final NamingStrategy | namingStrategy
The naming strategy to use. |
protected final TypeValidation | typeValidation
Determines if a type should be explicitly validated. |
protected final VisibilityBridgeStrategy | visibilityBridgeStrategy
The visibility bridge strategy to apply. |
Access | Constructor and Description |
---|---|
public | ByteBuddy()
Creates a new Byte Buddy instance with a default configuration that is suitable for most use cases. |
public | ByteBuddy(ClassFileVersion
The class file version to use for types that are not based on an existing class file. classFileVersion)Creates a new Byte Buddy instance with a default configuration that is suitable for most use cases. |
protected | ByteBuddy(ClassFileVersion
The class file version to use for types that are not based on an existing class file. classFileVersion, NamingStrategy The naming strategy to use. namingStrategy, AuxiliaryType.The naming strategy to use for naming auxiliary types. auxiliaryTypeNamingStrategy,The annotation value filter factory to use. annotationValueFilterFactory,The annotation retention strategy to use. annotationRetention, Implementation.The implementation context factory to use. implementationContextFactory,The method graph compiler to use. methodGraphCompiler,The instrumented type factory to use. instrumentedTypeFactory,Determines if a type should be explicitly validated. typeValidation, VisibilityBridgeStrategy The visibility bridge strategy to apply. visibilityBridgeStrategy, ClassWriterStrategy The class writer strategy to use. classWriterStrategy, LatentMatcher<? super MethodDescription> A matcher for identifying methods that should be excluded from instrumentation. ignoredMethods)Creates a new Byte Buddy instance. |
Modifier and Type | Method and Description |
---|---|
public < The loaded type of the decorated type. T> DynamicType. | Returns: A type builder for decorating the provided type.The type to decorate. type)
Decorates a type with |
public < The loaded type of the decorated type. T> DynamicType. | Returns: A type builder for decorating the provided type.The type to decorate. type, ClassFileLocator The class file locator to use. classFileLocator)
Decorates a type with |
public < The loaded type of the decorated type. T> DynamicType. | Returns: A type builder for decorating the provided type.The type to decorate. type, ClassFileLocator The class file locator to use. classFileLocator)
Decorates a type with |
private static < The type of the action's resolved value. T> T | Returns: The action's resolved value.The action to execute from a privileged context. action)A proxy for |
public ByteBuddy | Returns: A new Byte Buddy instance that excludes any method from instrumentation if it is matched by the supplied matcher.A matcher for identifying methods to be excluded from instrumentation. ignoredMethods)Creates a new configuration where any |
public ByteBuddy | Returns: A new Byte Buddy instance that excludes any method from instrumentation if it is matched by the supplied matcher.A matcher for identifying methods to be excluded from instrumentation. ignoredMethods)
Creates a new configuration where any |
public DynamicType. | Returns: A type builder that creates a newAnnotation type.
Creates a new |
public DynamicType. | Returns: A type builder for creating an enumeration type.The names of the type's enumeration constants value)
Creates a new |
public DynamicType. | Returns: A type builder for creating an enumeration type.The names of the type's enumeration constants values)
Creates a new |
public DynamicType. | Returns: A type builder that creates a new interface type.Creates a new, plain interface type. |
public < A loaded type that the generated interface is guaranteed to inherit. T> DynamicType. | Returns: A type builder that creates a new interface type.An interface type that the generated interface implements. interfaceType)Creates a new interface type that extends the provided interface. |
public DynamicType. | Returns: A type builder that creates a new interface type.The interface types to implement. The types must be raw or parameterized types. All type
variables that are referenced by a parameterized type must be declared by the generated
subclass before creating the type. interfaceType)Creates a new interface type that extends the provided interface. |
public DynamicType. | Returns: A type builder that creates a new interface type.The interface types to implement. The types must be raw or parameterized types. All
type variables that are referenced by a parameterized type must be declared by the
generated subclass before creating the type. interfaceTypes)Creates a new interface type that extends the provided interface. |
public DynamicType. | Returns: A type builder that creates a new interface type.The interface types to implement. The types must be raw or parameterized types. All
type variables that are referenced by a parameterized type must be declared by the
generated subclass before creating the type. interfaceType)Creates a new interface type that extends the provided interface. |
public DynamicType. | Returns: A type builder that creates a new interface type.The interface types to implement. The types must be raw or parameterized types. All
type variables that are referenced by a parameterized type must be declared by the
generated subclass before creating the type. interfaceTypes)Creates a new interface type that extends the provided interface. |
public DynamicType. | Returns: A type builder that creates apackage-info class file.The fully qualified name of the package. name)Creates a new package definition. |
public DynamicType. | |
public < The loaded type of the rebased type. T> DynamicType. | Returns: A type builder for rebasing the provided type.The type that is being rebased. type)Rebases the given type where any intercepted method that is declared by the redefined type is preserved within the rebased type's class such that the class's original can be invoked from the new method implementations. |
public < The loaded type of the rebased type. T> DynamicType. | Returns: A type builder for rebasing the provided type.The type that is being rebased. type, ClassFileLocator The class file locator that is queried for the rebased type's class file. classFileLocator)Rebases the given type where any intercepted method that is declared by the redefined type is preserved within the rebased type's class such that the class's original can be invoked from the new method implementations. |
public < The loaded type of the rebased type. T> DynamicType. | Returns: A type builder for rebasing the provided type.The type that is being rebased. type, ClassFileLocator The class file locator that is queried for the rebased type's class file. classFileLocator, MethodNameTransformer The method name transformer for renaming a method that is rebased. methodNameTransformer)Rebases the given type where any intercepted method that is declared by the redefined type is preserved within the rebased type's class such that the class's original can be invoked from the new method implementations. |
public < The loaded type of the rebased type. T> DynamicType. | Returns: A type builder for rebasing the provided type.The type that is being rebased. type, ClassFileLocator The class file locator that is queried for the rebased type's class file. classFileLocator)Rebases the given type where any intercepted method that is declared by the redefined type is preserved within the rebased type's class such that the class's original can be invoked from the new method implementations. |
public < The loaded type of the rebased type. T> DynamicType. | Returns: A type builder for rebasing the provided type.The type that is being rebased. type, ClassFileLocator The class file locator that is queried for the rebased type's class file. classFileLocator, MethodNameTransformer The method name transformer for renaming a method that is rebased. methodNameTransformer)Rebases the given type where any intercepted method that is declared by the redefined type is preserved within the rebased type's class such that the class's original can be invoked from the new method implementations. |
public DynamicType. | Returns: A type builder for rebasing the given package.The package that is being rebased. aPackage, ClassFileLocator The class file locator to use for locating the package's class file. classFileLocator)Rebases a package. |
public DynamicType. | Returns: A type builder for rebasing the given package.The package that is being rebased. aPackage, ClassFileLocator The class file locator to use for locating the package's class file. classFileLocator)Rebases a package. |
public < The loaded type of the redefined type. T> DynamicType. | |
public < The loaded type of the redefined type. T> DynamicType. | Returns: A type builder for redefining the provided type.The type that is being redefined. type, ClassFileLocator The class file locator that is queried for the redefined type's class file. classFileLocator)Redefines the given type where any intercepted method that is declared by the redefined type is fully replaced by the new implementation. |
public < The loaded type of the redefined type. T> DynamicType. | Returns: A type builder for redefining the provided type.The type that is being redefined. type, ClassFileLocator The class file locator that is queried for the redefined type's class file. classFileLocator)Redefines the given type where any intercepted method that is declared by the redefined type is fully replaced by the new implementation. |
public < A loaded type that the generated class is guaranteed to inherit. T> DynamicType. | |
public < A loaded type that the generated class is guaranteed to inherit. T> DynamicType. | Returns: A type builder for creating a new class extending the provided class or interface.The super class or interface type to extend. superType, ConstructorStrategy A constructor strategy that determines the constructorStrategy)Creates a new builder for subclassing the provided type. |
public DynamicType. | Returns: A type builder for creating a new class extending the provided class or interface.The super class or interface type to extend. The type must be a raw type or parameterized type. All type
variables that are referenced by the generic type must be declared by the generated subclass before creating
the type. superType)Creates a new builder for subclassing the provided type. |
public DynamicType. | Returns: A type builder for creating a new class extending the provided class or interface.The super class or interface type to extend. The type must be a raw type or parameterized
type. All type variables that are referenced by the generic type must be declared by the
generated subclass before creating the type. superType, ConstructorStrategy A constructor strategy that determines the constructorStrategy)Creates a new builder for subclassing the provided type. |
public DynamicType. | Returns: A type builder for creating a new class extending the provided class or interface.The super class or interface type to extend. The type must be a raw type or parameterized type. All type
variables that are referenced by the generic type must be declared by the generated subclass before creating
the type. superType)Creates a new builder for subclassing the provided type. |
public DynamicType. | Returns: A type builder for creating a new class extending the provided class or interface.The super class or interface type to extend. The type must be a raw type or parameterized
type. All type variables that are referenced by the generic type must be declared by the
generated subclass before creating the type. superType, ConstructorStrategy A constructor strategy that determines the constructorStrategy)Creates a new builder for subclassing the provided type. |
public ByteBuddy | Returns: A new Byte Buddy instance that uses the supplied class file version.The class file version to use for types that are not based on an existing class file. classFileVersion)Creates a new configuration where all class files that are not based on an existing class file are created using the supplied class file version. |
public ByteBuddy | Returns: A new Byte Buddy instance that uses the supplied naming strategy.The naming strategy to apply when creating a new dynamic type. namingStrategy)Creates a new configuration where new types are named by applying the given naming strategy. |
public ByteBuddy | Returns: A new Byte Buddy instance that uses the supplied naming strategy for auxiliary types.The naming strategy to apply when creating a new auxiliary type. auxiliaryTypeNamingStrategyCreates a new configuration where auxiliary types are named by applying the given naming strategy. |
public ByteBuddy | Returns: A new Byte Buddy instance that uses the supplied annotation value filter factory.The annotation value filter factory to use. annotationValueFilterFactoryCreates a new configuration where annotation values are written according to the given filter factory. |
public ByteBuddy | Returns: A new Byte Buddy instance that uses the supplied annotation retention strategy.The annotation retention strategy to use. annotationRetention)Creates a new configuration where annotations that are found in an existing class file are or are not preserved in the format they are discovered, i.e. rewritten in the format they were already present in the class file. |
public ByteBuddy | Returns: A new Byte Buddy instance that uses the supplied implementation context factory.The implementation context factory to use for defining an instrumented type. implementationContextFactoryCreates a new configuration where the |
public ByteBuddy | Returns: A new Byte Buddy instance that uses the supplied method graph compiler.The method graph compiler to use for analyzing the instrumented type. methodGraphCompilerCreates a new configuration where the |
public ByteBuddy | Returns: A new Byte Buddy instance that uses the supplied factory for creating instrumented types.The factory to use when creating instrumented types. instrumentedTypeFactoryConfigures Byte Buddy to use the specified factory for creating |
public ByteBuddy | Returns: A new Byte Buddy instance that applies the supplied type validation.The type validation to apply during type creation. typeValidation)Creates a new configuration that applies the supplied type validation. |
public ByteBuddy | Returns: A new Byte Buddy instance that applies the supplied visibility bridge strategy.The visibility bridge strategy to apply. visibilityBridgeStrategy)Creates a new configuration that applies the supplied visibility bridge strategy. |
public ByteBuddy | Returns: A new Byte Buddy instance that applies the supplied class writer strategy.The class writer strategy to apply during type creation. classWriterStrategy)Creates a new configuration that applies the supplied class writer strategy. |