changeset 8337:8b37c5a17316

8162766: Unsafe_DefineClass0 accesses raw oops while in _thread_in_native Summary: Go to thread_in_vm to get the class_loader oop. Also reviewed by leelamohan.venati@gmail.com. Reviewed-by: sspitsyn
author coleenp
date Tue, 11 Oct 2016 14:07:13 -0400
parents 079d89ac8f34
children 971b3f90ebdc d2e8a8cd4166
files src/share/vm/prims/unsafe.cpp
diffstat 1 files changed, 1 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/prims/unsafe.cpp	Tue Oct 11 18:40:11 2016 +0300
+++ b/src/share/vm/prims/unsafe.cpp	Tue Oct 11 14:07:13 2016 -0400
@@ -985,14 +985,6 @@
   }
 UNSAFE_END
 
-static jobject get_class_loader(JNIEnv* env, jclass cls) {
-  if (java_lang_Class::is_primitive(JNIHandles::resolve_non_null(cls))) {
-    return NULL;
-  }
-  Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls));
-  oop loader = k->class_loader();
-  return JNIHandles::make_local(env, loader);
-}
 
 UNSAFE_ENTRY(jclass, Unsafe_DefineClass0(JNIEnv *env, jobject unsafe, jstring name, jbyteArray data, int offset, int length))
   UnsafeWrapper("Unsafe_DefineClass");
@@ -1001,7 +993,7 @@
 
     int depthFromDefineClass0 = 1;
     jclass  caller = JVM_GetCallerClass(env, depthFromDefineClass0);
-    jobject loader = (caller == NULL) ? NULL : get_class_loader(env, caller);
+    jobject loader = (caller == NULL) ? NULL : JVM_GetClassLoader(env, caller);
     jobject pd     = (caller == NULL) ? NULL : JVM_GetProtectionDomain(env, caller);
 
     return Unsafe_DefineClass_impl(env, name, data, offset, length, loader, pd);