7127032: fix for 7122253 adds a JvmtiThreadState earlier than necessary
authordcubed
Thu, 05 Jan 2012 06:24:52 -0800
changeset 11419 af92c7669f5a
parent 11418 66ca80da30e2
child 11420 22ec1bad0dce
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
hotspot/src/share/vm/classfile/classFileParser.cpp
--- a/hotspot/src/share/vm/classfile/classFileParser.cpp	Tue Jan 03 15:11:31 2012 -0500
+++ b/hotspot/src/share/vm/classfile/classFileParser.cpp	Thu Jan 05 06:24:52 2012 -0800
@@ -2664,18 +2664,23 @@
   _max_bootstrap_specifier_index = -1;
 
   if (JvmtiExport::should_post_class_file_load_hook()) {
-    // Get the cached class file bytes (if any) from the
-    // class that is being redefined.
-    JvmtiThreadState *state = JvmtiThreadState::state_for(jt);
-    KlassHandle      *h_class_being_redefined =
-                        state->get_class_being_redefined();
-    if (h_class_being_redefined != NULL) {
-      instanceKlassHandle ikh_class_being_redefined =
-        instanceKlassHandle(THREAD, (*h_class_being_redefined)());
-      cached_class_file_bytes =
-        ikh_class_being_redefined->get_cached_class_file_bytes();
-      cached_class_file_length =
-        ikh_class_being_redefined->get_cached_class_file_len();
+    // Get the cached class file bytes (if any) from the class that
+    // is being redefined or retransformed. We use jvmti_thread_state()
+    // instead of JvmtiThreadState::state_for(jt) so we don't allocate
+    // a JvmtiThreadState any earlier than necessary. This will help
+    // avoid the bug described by 7126851.
+    JvmtiThreadState *state = jt->jvmti_thread_state();
+    if (state != NULL) {
+      KlassHandle *h_class_being_redefined =
+                     state->get_class_being_redefined();
+      if (h_class_being_redefined != NULL) {
+        instanceKlassHandle ikh_class_being_redefined =
+          instanceKlassHandle(THREAD, (*h_class_being_redefined)());
+        cached_class_file_bytes =
+          ikh_class_being_redefined->get_cached_class_file_bytes();
+        cached_class_file_length =
+          ikh_class_being_redefined->get_cached_class_file_len();
+      }
     }
 
     unsigned char* ptr = cfs->buffer();