import net.bytebuddy.ByteBuddy;
import net.bytebuddy.implementation.FixedValue;
import net.bytebuddy.matcher.ElementMatchers;
public class HelloWorldAgent {
public static void main(String[] args) throws Exception {
Class<?> dynamicType = new ByteBuddy()
.subclass(Object.class)
.method(ElementMatchers.named("toString"))
.intercept(FixedValue.value("Hello World!"))
.make()
.load(HelloWorldAgent.class.getClassLoader())
.getLoaded();
System.out.println(dynamicType.newInstance().toString());
}
}