changeset 8503:c8fcec7a9a4c

8157739: Classloader Consistency Checking Reviewed-by: ahgross, akulyakh, dfuchs, jwilhelm, skoivu
author hb
date Tue, 12 Jul 2016 16:46:45 +0100
parents 9b5e369bfe92
children b8b8ef427a7a
files src/share/classes/com/sun/jmx/remote/util/ClassLoaderWithRepository.java
diffstat 1 files changed, 11 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/jmx/remote/util/ClassLoaderWithRepository.java	Fri Jul 01 14:09:46 2016 -0700
+++ b/src/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;