I want to get all fields values that are in my dynamic type. I got all fields:
Class myDynamicClass = Class.forName("SampleDynamic");
Field[] fieldArr = myDynamicClass.getDeclaredFields();
I want to get their values, so I tried to use FieldAccessor.of(fieldArr[i])
, but didn't understand what should I do next.
my builder class was:
classBuilder = new ByteBuddy().subclass(Sample.class,ConstructorStrategy.Default.NO_CONSTRUCTORS).
name("SampleDynamic").
defineField("myField", String.class, Visibility.PRIVATE).
defineConstructor(Visibility.PUBLIC).withParameters(String.class, String.class, String.class).
intercept(MethodCall.invoke(Sample.class.getConstructor(String.class, String.class)).withArgument(0,1).
andThen(FieldAccessor.ofField("myField").setsArgumentAt(2)));
thanks
Aucun commentaire:
Enregistrer un commentaire