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.
pull/9/head
Phillip Webb 12 years ago
parent dc1b787a01
commit 8d39abb8d9

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

Loading…
Cancel
Save