Defensively use Class.forName instead of ClassLoader.loadClass

Issue: SPR-17333
This commit is contained in:
Juergen Hoeller
2018-10-09 23:14:05 +02:00
parent d9e7253532
commit fdf340306d
2 changed files with 5 additions and 5 deletions

View File

@@ -272,7 +272,7 @@ public abstract class ClassUtils {
clToUse = getDefaultClassLoader();
}
try {
return (clToUse != null ? clToUse.loadClass(name) : Class.forName(name));
return Class.forName(name, false, clToUse);
}
catch (ClassNotFoundException ex) {
int lastDotIndex = name.lastIndexOf(PACKAGE_SEPARATOR);
@@ -280,7 +280,7 @@ public abstract class ClassUtils {
String innerClassName =
name.substring(0, lastDotIndex) + INNER_CLASS_SEPARATOR + name.substring(lastDotIndex + 1);
try {
return (clToUse != null ? clToUse.loadClass(innerClassName) : Class.forName(innerClassName));
return Class.forName(innerClassName, false, clToUse);
}
catch (ClassNotFoundException ex2) {
// Swallow - let original exception get through