Skip navigation links

Package net.bytebuddy

Byte Buddy is a library for creating Java classes at runtime of a Java program.

See: Description

Package net.bytebuddy Description

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!.
Skip navigation links

Copyright © 2014–2018. All rights reserved.