src/share/vm/prims/jvmtiExport.cpp

Print this page




 648       for (JvmtiEnv* env = it.first(); env != NULL; env = it.next(env)) {
 649         if (!env->is_retransformable() && env->is_enabled(JVMTI_EVENT_CLASS_FILE_LOAD_HOOK)) {
 650           // non-retransformable agents cannot retransform back,
 651           // so no need to cache the original class file bytes
 652           post_to_env(env, false);
 653         }
 654       }
 655     }
 656     JvmtiEnvIterator it;
 657     for (JvmtiEnv* env = it.first(); env != NULL; env = it.next(env)) {
 658       // retransformable agents get all events
 659       if (env->is_retransformable() && env->is_enabled(JVMTI_EVENT_CLASS_FILE_LOAD_HOOK)) {
 660         // retransformable agents need to cache the original class file
 661         // bytes if changes are made via the ClassFileLoadHook
 662         post_to_env(env, true);
 663       }
 664     }
 665   }
 666 
 667   void post_to_env(JvmtiEnv* env, bool caching_needed) {
 668     if (env->phase() == JVMTI_PHASE_PRIMORDIAL) {
 669       return;
 670     }
 671     unsigned char *new_data = NULL;
 672     jint new_len = 0;
 673 //    EVT_TRACE(JVMTI_EVENT_CLASS_FILE_LOAD_HOOK,
 674 //     ("JVMTI [%s] class file load hook event sent %s  data_ptr = %d, data_len = %d",
 675 //               JvmtiTrace::safe_get_thread_name(_thread),
 676 //               _h_name == NULL ? "NULL" : _h_name->as_utf8(),
 677 //               _curr_data, _curr_len ));
 678     JvmtiClassFileLoadEventMark jem(_thread, _h_name, _class_loader,
 679                                     _h_protection_domain,
 680                                     _h_class_being_redefined);
 681     JvmtiJavaThreadEventTransition jet(_thread);
 682     jvmtiEventClassFileLoadHook callback = env->callbacks()->ClassFileLoadHook;
 683     if (callback != NULL) {
 684       (*callback)(env->jvmti_external(), jem.jni_env(),
 685                   jem.class_being_redefined(),
 686                   jem.jloader(), jem.class_name(),
 687                   jem.protection_domain(),
 688                   _curr_len, _curr_data,




 648       for (JvmtiEnv* env = it.first(); env != NULL; env = it.next(env)) {
 649         if (!env->is_retransformable() && env->is_enabled(JVMTI_EVENT_CLASS_FILE_LOAD_HOOK)) {
 650           // non-retransformable agents cannot retransform back,
 651           // so no need to cache the original class file bytes
 652           post_to_env(env, false);
 653         }
 654       }
 655     }
 656     JvmtiEnvIterator it;
 657     for (JvmtiEnv* env = it.first(); env != NULL; env = it.next(env)) {
 658       // retransformable agents get all events
 659       if (env->is_retransformable() && env->is_enabled(JVMTI_EVENT_CLASS_FILE_LOAD_HOOK)) {
 660         // retransformable agents need to cache the original class file
 661         // bytes if changes are made via the ClassFileLoadHook
 662         post_to_env(env, true);
 663       }
 664     }
 665   }
 666 
 667   void post_to_env(JvmtiEnv* env, bool caching_needed) {
 668     if (env->phase() == JVMTI_PHASE_PRIMORDIAL && !env->early_class_hook_env()) {
 669       return;
 670     }
 671     unsigned char *new_data = NULL;
 672     jint new_len = 0;
 673 //    EVT_TRACE(JVMTI_EVENT_CLASS_FILE_LOAD_HOOK,
 674 //     ("JVMTI [%s] class file load hook event sent %s  data_ptr = %d, data_len = %d",
 675 //               JvmtiTrace::safe_get_thread_name(_thread),
 676 //               _h_name == NULL ? "NULL" : _h_name->as_utf8(),
 677 //               _curr_data, _curr_len ));
 678     JvmtiClassFileLoadEventMark jem(_thread, _h_name, _class_loader,
 679                                     _h_protection_domain,
 680                                     _h_class_being_redefined);
 681     JvmtiJavaThreadEventTransition jet(_thread);
 682     jvmtiEventClassFileLoadHook callback = env->callbacks()->ClassFileLoadHook;
 683     if (callback != NULL) {
 684       (*callback)(env->jvmti_external(), jem.jni_env(),
 685                   jem.class_being_redefined(),
 686                   jem.jloader(), jem.class_name(),
 687                   jem.protection_domain(),
 688                   _curr_len, _curr_data,