net.bytebuddy.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 java.lang.Object class which implements the java.io.Serializable
interface. The java.lang.Object#toString() method is overridden to return Hello World!.
| Modifier and Type | Interface and Description |
|---|---|
| public interface | NamingStrategy
A naming strategy for determining a fully qualified name for a dynamically created Java type. |
| Modifier and Type | Class and Description |
|---|---|
| public class | 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. |
| public class | ClassFileVersion
A wrapper object for representing a validated class file version in the format that is specified by the JVMS. |
| public class | TypeCache<
The type of the key that is used for identifying stored classes per class loader. Such keys must not strongly reference any
types or class loaders without potentially corrupting the garbage eligibility of stored classes. As the storage is segmented
by class loader, it is normally sufficient to store types by their name. T>A cache for storing types without strongly referencing any class loader or type. |