Extract package discovery to separate method
This commit is contained in:
parent
4cfc7b6ad9
commit
ea59976277
|
@ -122,7 +122,9 @@ public class LaunchedURLClassLoader extends URLClassLoader {
|
||||||
|
|
||||||
// 2) Try to find locally
|
// 2) Try to find locally
|
||||||
try {
|
try {
|
||||||
return findClass(name);
|
findPackage(name);
|
||||||
|
Class<?> cls = findClass(name);
|
||||||
|
return cls;
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
}
|
}
|
||||||
|
@ -131,8 +133,7 @@ public class LaunchedURLClassLoader extends URLClassLoader {
|
||||||
return super.loadClass(name, false);
|
return super.loadClass(name, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private void findPackage(final String name) throws ClassNotFoundException {
|
||||||
protected Class<?> findClass(final String name) throws ClassNotFoundException {
|
|
||||||
int lastDot = name.lastIndexOf('.');
|
int lastDot = name.lastIndexOf('.');
|
||||||
if (lastDot != -1) {
|
if (lastDot != -1) {
|
||||||
String packageName = name.substring(0, lastDot);
|
String packageName = name.substring(0, lastDot);
|
||||||
|
@ -145,14 +146,13 @@ public class LaunchedURLClassLoader extends URLClassLoader {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return super.findClass(name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Define a package before a {@code findClass} call is made. This is necessary to
|
* Define a package before a {@code findClass} call is made. This is necessary to
|
||||||
* ensure that the appropriate manifest for nested JARs associated with the package.
|
* ensure that the appropriate manifest for nested JARs associated with the package.
|
||||||
* @param name the class name being found
|
* @param name the class name being found
|
||||||
* @param packageName the pacakge
|
* @param packageName the package
|
||||||
*/
|
*/
|
||||||
private void definePackageForFindClass(final String name, final String packageName) {
|
private void definePackageForFindClass(final String name, final String packageName) {
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue