diff -r 0cd18aa4f7b6 -r 7437dc810834 src/hotspot/share/oops/generateOopMap.cpp --- a/src/hotspot/share/oops/generateOopMap.cpp Fri Nov 10 09:16:42 2017 +0100 +++ b/src/hotspot/share/oops/generateOopMap.cpp Fri Nov 10 13:10:54 2017 +0100 @@ -2146,8 +2146,14 @@ // Append method name char msg_buffer2[512]; jio_snprintf(msg_buffer2, sizeof(msg_buffer2), "%s in method %s", msg_buffer, method()->name()->as_C_string()); - _exception = Exceptions::new_exception(Thread::current(), - vmSymbols::java_lang_LinkageError(), msg_buffer2); + if (Thread::current()->can_call_java()) { + _exception = Exceptions::new_exception(Thread::current(), + vmSymbols::java_lang_LinkageError(), msg_buffer2); + } else { + // We cannot instantiate an exception object from a compiler thread. + // Exit the VM with a useful error message. + fatal("%s", msg_buffer2); + } } void GenerateOopMap::report_error(const char *format, ...) { @@ -2159,14 +2165,7 @@ void GenerateOopMap::verify_error(const char *format, ...) { // We do not distinguish between different types of errors for verification // errors. Let the verifier give a better message. - const char *msg = "Illegal class file encountered. Try running with -Xverify:all"; - _got_error = true; - // Append method name - char msg_buffer2[512]; - jio_snprintf(msg_buffer2, sizeof(msg_buffer2), "%s in method %s", msg, - method()->name()->as_C_string()); - _exception = Exceptions::new_exception(Thread::current(), - vmSymbols::java_lang_LinkageError(), msg_buffer2); + report_error("Illegal class file encountered. Try running with -Xverify:all"); } //