8189123: More consistent classloading
authorhseigel
Tue, 07 Nov 2017 16:07:36 -0500
changeset 49770 0a8a11767c3d
parent 49768 54d462a2db54
child 49771 07556bea9c5c
8189123: More consistent classloading Reviewed-by: acorn, ahgross, rhalade Contributed-by: harold.seigel@oracle.com
src/hotspot/share/classfile/verificationType.cpp
src/hotspot/share/classfile/verifier.cpp
src/hotspot/share/prims/jvm.cpp
--- a/src/hotspot/share/classfile/verificationType.cpp	Tue Apr 17 16:18:22 2018 -0400
+++ b/src/hotspot/share/classfile/verificationType.cpp	Tue Nov 07 16:07:36 2017 -0500
@@ -50,6 +50,7 @@
   Klass* this_class = SystemDictionary::resolve_or_fail(
       name, Handle(THREAD, klass->class_loader()),
       Handle(THREAD, klass->protection_domain()), true, CHECK_false);
+  klass->class_loader_data()->record_dependency(this_class);
   if (log_is_enabled(Debug, class, resolve)) {
     Verifier::trace_class_resolution(this_class, klass);
   }
@@ -67,6 +68,7 @@
     Klass* from_class = SystemDictionary::resolve_or_fail(
         from_name, Handle(THREAD, klass->class_loader()),
         Handle(THREAD, klass->protection_domain()), true, CHECK_false);
+    klass->class_loader_data()->record_dependency(from_class);
     if (log_is_enabled(Debug, class, resolve)) {
       Verifier::trace_class_resolution(from_class, klass);
     }
--- a/src/hotspot/share/classfile/verifier.cpp	Tue Apr 17 16:18:22 2018 -0400
+++ b/src/hotspot/share/classfile/verifier.cpp	Tue Nov 07 16:07:36 2017 -0500
@@ -2013,9 +2013,12 @@
     name, Handle(THREAD, loader), Handle(THREAD, protection_domain),
     true, THREAD);
 
-  if (log_is_enabled(Debug, class, resolve)) {
-    InstanceKlass* cur_class = InstanceKlass::cast(current_class());
-    Verifier::trace_class_resolution(kls, cur_class);
+  if (kls != NULL) {
+    current_class()->class_loader_data()->record_dependency(kls);
+    if (log_is_enabled(Debug, class, resolve)) {
+      InstanceKlass* cur_class = InstanceKlass::cast(current_class());
+      Verifier::trace_class_resolution(kls, cur_class);
+    }
   }
   return kls;
 }
--- a/src/hotspot/share/prims/jvm.cpp	Tue Apr 17 16:18:22 2018 -0400
+++ b/src/hotspot/share/prims/jvm.cpp	Tue Nov 07 16:07:36 2017 -0500
@@ -839,6 +839,11 @@
   Handle h_prot  (THREAD, protection_domain);
   jclass result = find_class_from_class_loader(env, h_name, init, h_loader,
                                                h_prot, true, thread);
+  if (result != NULL) {
+    oop mirror = JNIHandles::resolve_non_null(result);
+    Klass* to_class = java_lang_Class::as_Klass(mirror);
+    ClassLoaderData::class_loader_data(h_loader())->record_dependency(to_class);
+  }
 
   if (log_is_enabled(Debug, class, resolve) && result != NULL) {
     // this function is generally only used for class loading during verification.