javassist
javassist copied to clipboard
javassist.CannotCompileException: [source error] no such field: populateUser
I want to make javaagent with javassist, and in sample project, there's dummy dao class. `public class UserDao {
public User populateUser(User user) {
user.setAddress(UUID.randomUUID().toString());
user.setAge((int) (System.currentTimeMillis() / 100000));
return user;
}
public User getUser(String name) {
return new User(name);
}
}`
and javassist throws an exception " javassist.CannotCompileException: [source error] no such field: populateUser" when call insertBefore method.
String methodName = method.getName(); method.addLocalVariable("__methodName", stringClass); method.insertBefore("__methodName = " + methodName + ";");
method is instance of CtMethod.
can anyone help on this? Thanks.
jdk: 1.8 javassist: 3.27