I have a base class
public abstract class Cache {
public abstract void load(Object input);
public abstract void dump(Object output);
}
Would like to subclass it in Bytebuddy and
Tried FieldAccessor
but seems the API isn't suited for this purpose? Couldn't find any solution online except for this ancient answer which is supposedly addressed but I can't find the corresponding code How to get the value from each field of a class with Byte Buddy?
Example
public class Input {
double foo;
String bar;
}
public class Output {
boolean z;
}
Based on this supplied classes (Input & Output), extend/implement a Cache class with bytebuddy such that it does the following
public class ByteBuddyCache extends Cache {
double foo;
String bar;
boolean z;
public void load(Object input) {
Input i = (Input) input;
this.foo = i.foo;
this.bar = i.bar;
}
public void dump(Object output) {
Output o = (Output) output;
o.z = this.z;
}
}
This would require you to create custom StackManipulation
s. In these, you would combine FieldAccess
objects and MethodVariableAccess
.