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:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user