8157739: Classloader Consistency Checking
authorhb
Tue, 12 Jul 2016 16:46:45 +0100
changeset 41576 96d3f5419106
parent 41575 12390e0aabc4
child 41577 d4852d03014f
8157739: Classloader Consistency Checking Reviewed-by: ahgross, akulyakh, dfuchs, jwilhelm, skoivu
jdk/src/java.management/share/classes/com/sun/jmx/remote/util/ClassLoaderWithRepository.java
--- a/jdk/src/java.management/share/classes/com/sun/jmx/remote/util/ClassLoaderWithRepository.java	Tue Jul 12 11:17:30 2016 +0300
+++ b/jdk/src/java.management/share/classes/com/sun/jmx/remote/util/ClassLoaderWithRepository.java	Tue Jul 12 16:46:45 2016 +0100
@@ -39,8 +39,9 @@
    }
 
     protected Class<?> findClass(String name) throws ClassNotFoundException {
+        Class<?> cls;
         try {
-            return repository.loadClass(name);
+            cls = repository.loadClass(name);
         } catch (ClassNotFoundException cne) {
             if (cl2 != null) {
                 return cl2.loadClass(name);
@@ -48,6 +49,15 @@
                 throw cne;
             }
         }
+
+        if(!cls.getName().equals(name)){
+            if (cl2 != null) {
+                return cl2.loadClass(name);
+            } else {
+                throw new ClassNotFoundException(name);
+            }
+        }
+        return cls;
     }
 
     private ClassLoaderRepository repository;