From 2ab2dc62cef1b642ed8ff7f571d3b061bc97fe50 Mon Sep 17 00:00:00 2001 From: Harsha Wardhana B Date: Tue, 12 Jul 2016 16:46:45 +0100 Subject: [PATCH] 8157739: Classloader Consistency Checking Reviewed-by: ahgross, akulyakh, dfuchs, jwilhelm, skoivu --- .../jmx/remote/util/ClassLoaderWithRepository.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/jdk/src/java.management/share/classes/com/sun/jmx/remote/util/ClassLoaderWithRepository.java b/jdk/src/java.management/share/classes/com/sun/jmx/remote/util/ClassLoaderWithRepository.java index 9433bf891e7..a5d337ff1d2 100644 --- a/jdk/src/java.management/share/classes/com/sun/jmx/remote/util/ClassLoaderWithRepository.java +++ b/jdk/src/java.management/share/classes/com/sun/jmx/remote/util/ClassLoaderWithRepository.java @@ -39,8 +39,9 @@ public class ClassLoaderWithRepository extends ClassLoader { } 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 @@ public class ClassLoaderWithRepository extends ClassLoader { throw cne; } } + + if(!cls.getName().equals(name)){ + if (cl2 != null) { + return cl2.loadClass(name); + } else { + throw new ClassNotFoundException(name); + } + } + return cls; } private ClassLoaderRepository repository;