8217765: Internal Error (javaCalls.cpp:61) guarantee(thread->can_call_java()) failed
authordholmes
Wed, 20 Feb 2019 19:41:43 -0500
changeset 53864 81a9748bc86c
parent 53863 d001808c57e8
child 53865 c925e36a8e6d
8217765: Internal Error (javaCalls.cpp:61) guarantee(thread->can_call_java()) failed Reviewed-by: rehn, redestad, coleenp
src/hotspot/share/oops/instanceKlass.cpp
--- a/src/hotspot/share/oops/instanceKlass.cpp	Wed Feb 20 16:15:02 2019 -0800
+++ b/src/hotspot/share/oops/instanceKlass.cpp	Wed Feb 20 19:41:43 2019 -0500
@@ -183,8 +183,14 @@
       if (name == k->name()) {
         log_trace(class, nestmates)("- Found it at nest_members[%d] => cp[%d]", i, cp_index);
 
-        // names match so check actual klass - this may trigger class loading if
-        // it doesn't match (but that should be impossible)
+        // Names match so check actual klass - this may trigger class loading if
+        // it doesn't match (though that should be impossible). But to be safe we
+        // have to check for a compiler thread executing here.
+        if (!THREAD->can_call_java() && !_constants->tag_at(cp_index).is_klass()) {
+          log_trace(class, nestmates)("- validation required resolution in an unsuitable thread");
+          return false;
+        }
+
         Klass* k2 = _constants->klass_at(cp_index, CHECK_false);
         if (k2 == k) {
           log_trace(class, nestmates)("- class is listed as a nest member");
@@ -296,7 +302,7 @@
            error);
       }
 
-      if (validationException != NULL) {
+      if (validationException != NULL && THREAD->can_call_java()) {
         ResourceMark rm(THREAD);
         Exceptions::fthrow(THREAD_AND_LOCATION,
                            validationException,