src/hotspot/share/oops/instanceKlass.cpp
changeset 53864 81a9748bc86c
parent 53838 c8c9bd65c198
child 53884 1a7b57d02107
--- 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,