changeset 18618:0aec14bcf006

ensure the error message about missing Graal classes is printed exactly once
author Doug Simon <doug.simon@oracle.com>
date Thu, 04 Dec 2014 15:28:02 +0100
parents c2da0aa9e675
children 965f1e08c083
files src/share/vm/graal/graalRuntime.cpp
diffstat 1 files changed, 12 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/graal/graalRuntime.cpp	Thu Dec 04 13:48:10 2014 +0100
+++ b/src/share/vm/graal/graalRuntime.cpp	Thu Dec 04 15:28:02 2014 +0100
@@ -770,15 +770,25 @@
     TempNewSymbol name = SymbolTable::new_symbol("com/oracle/graal/hotspot/loader/Factory", CHECK_ABORT);
     KlassHandle klass = SystemDictionary::resolve_or_fail(name, true, THREAD);
     if (HAS_PENDING_EXCEPTION) {
-      abort_on_pending_exception(PENDING_EXCEPTION, "Graal classes are not available");
+      static volatile int seen_error = 0;
+      if (!seen_error && Atomic::cmpxchg(1, &seen_error, 0) == 0) {
+        // Only report the failure on the first thread that hits it
+        abort_on_pending_exception(PENDING_EXCEPTION, "Graal classes are not available");
+      } else {
+        CLEAR_PENDING_EXCEPTION;
+        // Give first thread time to report the error.
+        os::sleep(THREAD, 100, false);
+        vm_abort(false);
+      }
     }
+
     TempNewSymbol field_name = SymbolTable::new_symbol("useGraalClassLoader", CHECK_ABORT);
-
     fieldDescriptor field_desc;
     if (klass->find_field(field_name, vmSymbols::bool_signature(), &field_desc) == NULL) {
       ResourceMark rm;
       fatal(err_msg("Invalid layout of %s at %s", field_name->as_C_string(), klass->external_name()));
     }
+
     InstanceKlass* ik = InstanceKlass::cast(klass());
     address addr = ik->static_field_addr(field_desc.offset() - InstanceMirrorKlass::offset_of_static_fields());
     *((jboolean *) addr) = (jboolean) UseGraalClassLoader;