Thu, 05 Jan 2012 06:24:52 -0800
7127032: fix for 7122253 adds a JvmtiThreadState earlier than necessary
Summary: Use JavaThread::jvmti_thread_state() instead of JvmtiThreadState::state_for().
Reviewed-by: coleenp, poonam, acorn
src/share/vm/classfile/classFileParser.cpp | file | annotate | diff | comparison | revisions |
1.1 --- a/src/share/vm/classfile/classFileParser.cpp Tue Jan 03 15:11:31 2012 -0500 1.2 +++ b/src/share/vm/classfile/classFileParser.cpp Thu Jan 05 06:24:52 2012 -0800 1.3 @@ -2664,18 +2664,23 @@ 1.4 _max_bootstrap_specifier_index = -1; 1.5 1.6 if (JvmtiExport::should_post_class_file_load_hook()) { 1.7 - // Get the cached class file bytes (if any) from the 1.8 - // class that is being redefined. 1.9 - JvmtiThreadState *state = JvmtiThreadState::state_for(jt); 1.10 - KlassHandle *h_class_being_redefined = 1.11 - state->get_class_being_redefined(); 1.12 - if (h_class_being_redefined != NULL) { 1.13 - instanceKlassHandle ikh_class_being_redefined = 1.14 - instanceKlassHandle(THREAD, (*h_class_being_redefined)()); 1.15 - cached_class_file_bytes = 1.16 - ikh_class_being_redefined->get_cached_class_file_bytes(); 1.17 - cached_class_file_length = 1.18 - ikh_class_being_redefined->get_cached_class_file_len(); 1.19 + // Get the cached class file bytes (if any) from the class that 1.20 + // is being redefined or retransformed. We use jvmti_thread_state() 1.21 + // instead of JvmtiThreadState::state_for(jt) so we don't allocate 1.22 + // a JvmtiThreadState any earlier than necessary. This will help 1.23 + // avoid the bug described by 7126851. 1.24 + JvmtiThreadState *state = jt->jvmti_thread_state(); 1.25 + if (state != NULL) { 1.26 + KlassHandle *h_class_being_redefined = 1.27 + state->get_class_being_redefined(); 1.28 + if (h_class_being_redefined != NULL) { 1.29 + instanceKlassHandle ikh_class_being_redefined = 1.30 + instanceKlassHandle(THREAD, (*h_class_being_redefined)()); 1.31 + cached_class_file_bytes = 1.32 + ikh_class_being_redefined->get_cached_class_file_bytes(); 1.33 + cached_class_file_length = 1.34 + ikh_class_being_redefined->get_cached_class_file_len(); 1.35 + } 1.36 } 1.37 1.38 unsigned char* ptr = cfs->buffer();