I want to modify my classes at runtime after the class prepare event is thrown which means the class file is arranged into the method area. ( This is in reference to the JVMTI )
My purpose of hooking into "Class Prepare" event instead of "Class File Load Hook" event is to avoid parsing the whole class file in the agent. ( As the VM itself will also be parsing it, this would result in a runtime overhead.)
But it seems that the API requires parsing even after the class is prepared already. Here is the callback method signature:
and here is the link to the documentation
Is there a way to get the constant pool, method areas of the prepared class so that I can modify just the part which is required and load the class again. ( instead of parsing the whole class file and then doing my modification and then loading )
I think, I got the motivation of your question.
You want some light weight API to redefine just part of a class, say, methods.
Example is inserting user-defined probes.
It is not supported in the current design however.
The following links can be useful: