More classpath mucking about in Sfl4jTestJarsRunner
This commit is contained in:
parent
9c9f2bd7c3
commit
c02f98b7e6
|
@ -24,63 +24,49 @@ public class Slf4jTestJarsRunner extends BlockJUnit4ClassRunner
|
||||||
{
|
{
|
||||||
private static class Slf4jTestClassLoader extends URLClassLoader
|
private static class Slf4jTestClassLoader extends URLClassLoader
|
||||||
{
|
{
|
||||||
|
private ClassLoader parent;
|
||||||
|
|
||||||
public Slf4jTestClassLoader(URL[] urls, ClassLoader parent)
|
public Slf4jTestClassLoader(URL[] urls, ClassLoader parent)
|
||||||
{
|
{
|
||||||
super(urls,parent);
|
super(urls,parent);
|
||||||
|
this.parent = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected synchronized Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException
|
public Class<?> loadClass(String name) throws ClassNotFoundException
|
||||||
{
|
{
|
||||||
System.err.printf("[slf4j.cl] loadClass(%s)%n",name);
|
System.err.printf("[slf4j.cl] loadClass(%s)%n",name);
|
||||||
|
|
||||||
ClassNotFoundException ex= null;
|
|
||||||
Class<?> c = null;
|
Class<?> c = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
c = this.findClass(name);
|
c = super.loadClass(name);
|
||||||
if ( resolve )
|
System.err.println("FOUND in slf4j classloader: " + name);
|
||||||
{
|
|
||||||
resolveClass(c);
|
|
||||||
}
|
|
||||||
return c;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (ClassNotFoundException e)
|
catch (ClassNotFoundException e)
|
||||||
{
|
{
|
||||||
ex= e;
|
System.err.println("Not found in slf4j classloader: " + name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c == null)
|
if (c == null)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
c = super.loadClass(name,resolve);
|
c = parent.loadClass(name);
|
||||||
|
System.err.println("FOUND in parent classloader: " + name);
|
||||||
}
|
}
|
||||||
catch (ClassNotFoundException e)
|
catch (ClassNotFoundException e)
|
||||||
{
|
{
|
||||||
ex= e;
|
System.err.println("Not found in parent classloader: " + name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw ex;
|
if (c != null)
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<?> loadClass(String name) throws ClassNotFoundException
|
|
||||||
{
|
{
|
||||||
System.err.printf("[slf4j.cl] loadClass(%s)%n",name);
|
System.err.printf("[slf4j.cl] loadClass(%s) -> %s%n",name,c);
|
||||||
return super.loadClass(name);
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
throw new ClassNotFoundException(name);
|
||||||
protected Class<?> findClass(String name) throws ClassNotFoundException
|
|
||||||
{
|
|
||||||
System.err.printf("[slf4j.cl] findClass(%s)%n",name);
|
|
||||||
return super.findClass(name);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue