Protect against multiple define package calls

Ensure that multiple calls to define package are not made when the
same class is contained in multiple jars.
This commit is contained in:
Phillip Webb 2013-07-13 22:44:27 -07:00
parent dc1b787a01
commit 8d39abb8d9

View File

@ -46,7 +46,12 @@ public class LaunchedURLClassLoader extends URLClassLoader {
if (lastDot != -1) {
String packageName = name.substring(0, lastDot);
if (getPackage(packageName) == null) {
definePackageForFindClass(name, packageName);
try {
definePackageForFindClass(name, packageName);
}
catch (Exception ex) {
// Swallow and continue
}
}
}
return super.findClass(name);
@ -72,6 +77,7 @@ public class LaunchedURLClassLoader extends URLClassLoader {
if (jarFile.getManifest() != null
&& jarFile.getJarEntry(path) != null) {
definePackage(packageName, jarFile.getManifest(), url);
return null;
}
}
}