src/hotspot/share/utilities/debug.cpp
changeset 53599 0de1f006d3c3
parent 52431 b0af758a092c
child 53659 da5dc7e654aa
--- a/src/hotspot/share/utilities/debug.cpp	Fri Feb 01 10:27:45 2019 +0100
+++ b/src/hotspot/share/utilities/debug.cpp	Sat Dec 08 12:09:59 2018 +0100
@@ -92,6 +92,21 @@
 #  endif
 #endif // PRODUCT
 
+#ifdef ASSERT
+// This is to test that error reporting works if we assert during dynamic
+// initialization of the hotspot. See JDK-8214975.
+struct Crasher {
+  Crasher() {
+    // Using getenv - no other mechanism would work yet.
+    const char* s = ::getenv("HOTSPOT_FATAL_ERROR_DURING_DYNAMIC_INITIALIZATION");
+    if (s != NULL && ::strcmp(s, "1") == 0) {
+      fatal("HOTSPOT_FATAL_ERROR_DURING_DYNAMIC_INITIALIZATION");
+    }
+  }
+};
+static Crasher g_crasher;
+#endif // ASSERT
+
 ATTRIBUTE_PRINTF(1, 2)
 void warning(const char* format, ...) {
   if (PrintWarnings) {