Package net.bytebuddy
Byte Buddy is a library for creating Java classes at runtime of a Java program. For this purpose, the
ByteBuddy class serves as an entry point. The following example
Class<?> dynamicType = new ByteBuddy()
.subclass(Object.class)
.implement(Serializable.class)
.intercept(named("toString"), FixedValue.value("Hello World!"))
.make()
.load(getClass().getClassLoader(), ClassLoadingStrategy.Default.WRAPPER)
.getLoaded();
dynamicType.newInstance().toString; // returns "Hello World!"
creates a subclass of the Object class which implements the Serializable
interface. The Object.toString() method is overridden to return Hello World!.-
Interface Summary Interface Description ClassFileVersion.VersionLocator A locator for the executing VM's Java version.NamingStrategy A naming strategy for determining a fully qualified name for a dynamically created Java type.NamingStrategy.SuffixingRandom.BaseNameResolver A base name resolver is responsible for resolving a name onto which the suffix is appended. -
Class Summary Class Description ByteBuddy Instances of this class serve as a focus point for configuration of the library's behavior and as an entry point to any form of code generation using the library.ByteBuddy.EnumerationImplementation An implementation fo thevaluesmethod of an enumeration type.ByteBuddy.EnumerationImplementation.InitializationAppender A byte code appender for the type initializer of any enumeration type.ByteBuddy.EnumerationImplementation.ValuesMethodAppender A byte code appender for thevaluesmethod of any enumeration type.ByteBuddy.RecordConstructorStrategy.Appender A byte code appender for accessors and the record constructor.ClassFileVersion A wrapper object for representing a validated class file version in the format that is specified by the JVMS.ClassFileVersion.VersionLocator.ForJava9CapableVm A version locator for a JVM of at least version 9.NamingStrategy.AbstractBase An abstract base implementation where the names of redefined and rebased types are retained.NamingStrategy.PrefixingRandom A naming strategy that creates a name by prefixing a given class and its package with another package and by appending a random number to the class's simple name.NamingStrategy.SuffixingRandom A naming strategy that creates a name by concatenating: The super classes package and name A given suffix string A random number Between all these elements, a$sign is included into the name to improve readability.NamingStrategy.SuffixingRandom.BaseNameResolver.ForFixedValue A base name resolver that simply returns a fixed value.NamingStrategy.SuffixingRandom.BaseNameResolver.ForGivenType Uses a specific type's name as the resolved name.TypeCache<T> A cache for storing types without strongly referencing any class loader or type.TypeCache.LookupKey A key used for looking up a previously inserted class loader cache.TypeCache.SimpleKey A simple key based on a collection of types where no type is strongly referenced.TypeCache.StorageKey A key used for storing a class loader cache reference.TypeCache.WithInlineExpunction<S> An implementation of aTypeCachewhere obsolete references are cleared upon any call. -
Enum Summary Enum Description ByteBuddy.RecordConstructorStrategy A constructor strategy for implementing a Java record.ByteBuddy.RecordObjectMethod Implements the object methods of the Java record type.ClassFileVersion.VersionLocator.CreationAction A creation action for a version locator.ClassFileVersion.VersionLocator.ForLegacyVm A version locator for a JVM that does not provide thejava.lang.Runtime.Versionclass.NamingStrategy.SuffixingRandom.BaseNameResolver.ForUnnamedType Uses the unnamed type's super type's name as the resolved name.TypeCache.Sort Determines the storage format for a cached type.