public byte[] transform(ClassLoader loader, String className, Class<?> clazz,
ProtectionDomain domain, byte[] bytes)
throws IllegalClassFormatException {
return inspectClass(className, clazz, bytes);
}
private byte[] inspectClass(String name, Class<?> clazz, byte[] b) {
System.out.println("here"); //OK I see this print
ClassPool pool = ClassPool.getDefault();
System.out.println("inclass"); //can't see it !!
}
What can happen in ClassPool.getDefault();?
I had the same problem, and found ClassPool.getDefault was not throwing Exception, but Throwable.
In fact, it was throwing java.lang.NoClassDefFoundError.
In my manifest, I had:
You likely just need to point the Boot-Class-Path to the javassist.jar file.
In my case, with the Boot-Class-Path above, I needed a lib directory with javassist.jar in it.
The mistake I made initially was putting javassist.jar inside the agent jar file
(THE FOLLOWING IS INCORRECT, FOR DEMONSTRATION PURPOSES ONLY):
Rather than putting javassist.jar inside the agent jar file, I put it in an external directory accessible to the program. After that change, it worked fine.