src/hotspot/share/prims/jni.cpp
changeset 47662 2493edd8b479
parent 47659 a8e9aff89f7b
child 47765 b7c7428eaab9
--- a/src/hotspot/share/prims/jni.cpp	Thu Oct 19 11:31:52 2017 -0700
+++ b/src/hotspot/share/prims/jni.cpp	Thu Oct 19 17:27:34 2017 -0700
@@ -396,10 +396,11 @@
   }
 
   //%note jni_3
-  Handle loader;
   Handle protection_domain;
   // Find calling class
   Klass* k = thread->security_get_caller_class(0);
+  // default to the system loader when no context
+  Handle loader(THREAD, SystemDictionary::java_system_loader());
   if (k != NULL) {
     // Special handling to make sure JNI_OnLoad and JNI_OnUnload are executed
     // in the correct class context.
@@ -424,11 +425,6 @@
     }
   }
 
-  if (loader.is_null()) {
-    // No context and use the system class loader
-    loader = Handle(THREAD, SystemDictionary::java_system_loader());
-  }
-
   TempNewSymbol sym = SymbolTable::new_symbol(name, CHECK_NULL);
   result = find_class_from_class_loader(env, sym, true, loader,
                                         protection_domain, true, thread);