It's my first experience with ByteBuddy and I'd like to dynamically create a subclass of java.lang.Object
with only one public field named myValue of type java.lang.String
and a default value of "Hello World !".
Unfortunately, after calling the myClass.newInstance() the field's value is null
(within the Eclipse debugger).
final Class<?> myClass = new ByteBuddy().subclass(Object.class).name("test.MyClass")
.defineField("myValue", String.class, Visibility.PUBLIC)
.value("Hello World !")
.make()
.load(getClass().getClassLoader(), ClassLoadingStrategy.Default.INJECTION).getLoaded();
Object myObject = myClass.newInstance();
Am I missing something here ?
I'm using Eclipse Mars.2, an Oracle JDK 1.7.0_75 and ByteBuddy-1.2.3