Commit ea599762 authored by Dave Syer's avatar Dave Syer

Extract package discovery to separate method

parent 4cfc7b6a
...@@ -122,7 +122,9 @@ public class LaunchedURLClassLoader extends URLClassLoader { ...@@ -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 { ...@@ -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 { ...@@ -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 {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment