8031376: TraceClassLoading expects there to be a (Java) caller when you load a class with the bootstrap class loader
authorsla
Wed, 08 Jan 2014 08:34:02 +0100
changeset 22485 598d024a4a49
parent 22201 9c2ccfa3a5fe
child 22486 5de5916f2485
8031376: TraceClassLoading expects there to be a (Java) caller when you load a class with the bootstrap class loader Reviewed-by: sla, dholmes Contributed-by: jeremymanson@google.com
hotspot/src/share/vm/classfile/classFileParser.cpp
--- a/hotspot/src/share/vm/classfile/classFileParser.cpp	Tue Jan 07 13:26:56 2014 -0500
+++ b/hotspot/src/share/vm/classfile/classFileParser.cpp	Wed Jan 08 08:34:02 2014 +0100
@@ -4098,8 +4098,12 @@
         tty->print("[Loaded %s from %s]\n", this_klass->external_name(),
                    cfs->source());
       } else if (class_loader.is_null()) {
-        if (THREAD->is_Java_thread()) {
-          Klass* caller = ((JavaThread*)THREAD)->security_get_caller_class(1);
+        Klass* caller =
+            THREAD->is_Java_thread()
+                ? ((JavaThread*)THREAD)->security_get_caller_class(1)
+                : NULL;
+        // caller can be NULL, for example, during a JVMTI VM_Init hook
+        if (caller != NULL) {
           tty->print("[Loaded %s by instance of %s]\n",
                      this_klass->external_name(),
                      InstanceKlass::cast(caller)->external_name());