1 Reply Latest reply on Nov 30, 2007 5:58 AM by 843810

    Redefining Classes without class parsing?

      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:

      void JNICALL
      ClassPrepare(jvmtiEnv *jvmti_env,
      JNIEnv* jni_env,
      jthread thread,
      jclass klass)

      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 )
        • 1. Re: Redefining Classes without class parsing?
          Hi Pankaj,

          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:

          Thank you for sharing the ideas!