I am new to Javassist and I already read some lessons related to it.
Since I need some kind of bytecode injection in each method to be injected or before the method exits, and get some statistics from this.
Through the javassit online tutorial, I discovered that we can create a new field for an existing class:
CtClass point = ClassPool.getDefault().get("Point"); CtField f = new CtField(CtClass.intType, "z", point); point.addField(f);
But the CtField type by default contains only a primitive type, is it possible to add a new field whose type is not primitive, for example ArrayList?
If I can add a new ArrayList field to an existing class, since the class does not import java.util.ArrayList, will this cause a compilation error?
source share