I have a problem using JVMTI_EVENT_CLASS_FILE_LOAD_HOOK in JVMTI. I encrypt my class file so that it does not begin with class file magic number(0xCAFEBABE).And I want to transform it in my CLASS_FILE_LOAD_HOOK Callback Function.But It seems that JVM will not load that class file, so I do not even have a chance to transform it. How should I do? Thanks in advance.
According to the JVMTI documentation, the JVMTI_EVENT_CLASS_FILE_LOAD_HOOK event is "sent when the VM obtains a class file data, but before it constructs the in-memory representation for that class."
In other words too late for what you're doing. It won't work.
according the article(http://java.sun.com/developer/technicalArticles/J2SE/jvm_ti/)，It seems that JVMTI_EVENT_CLASS_FILE_LOAD_HOOK is the first event triggerd by JVM,early than JVMTI_EVENT_VM_START and JVMTI_EVENT_VM_INIT。