Fix #493 OSGiClassLoader contains dead code

Signed-off-by: laeubi <laeubi@laeubi-soft.de>
This commit is contained in:
laeubi 2016-04-08 08:46:26 +02:00
parent 2fb9b55da2
commit a8485140c9
1 changed files with 2 additions and 47 deletions

View File

@ -43,7 +43,6 @@ public class OSGiClassLoader extends URLClassLoader
private Bundle _bundle; private Bundle _bundle;
private ClassLoader _osgiBundleClassLoader; private ClassLoader _osgiBundleClassLoader;
private boolean _lookInOsgiFirst = true;
private ClassLoader _parent; private ClassLoader _parent;
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
@ -69,14 +68,6 @@ public class OSGiClassLoader extends URLClassLoader
boolean tried_parent= false; boolean tried_parent= false;
if (_parent!=null && !_lookInOsgiFirst)
{
tried_parent= true;
if (_parent!=null)
url= _parent.getResource(name);
}
if (url == null) if (url == null)
{ {
url = _osgiBundleClassLoader.getResource(name); url = _osgiBundleClassLoader.getResource(name);
@ -118,21 +109,6 @@ public class OSGiClassLoader extends URLClassLoader
ClassNotFoundException ex= null; ClassNotFoundException ex= null;
boolean tried_parent= false; boolean tried_parent= false;
if (c == null && _parent!=null && !_lookInOsgiFirst)
{
tried_parent= true;
try
{
c= _parent.loadClass(name);
if (LOG.isDebugEnabled())
LOG.debug("loaded " + c);
}
catch (ClassNotFoundException e)
{
ex= e;
}
}
if (c == null) if (c == null)
{ {
try try
@ -166,36 +142,15 @@ public class OSGiClassLoader extends URLClassLoader
{ {
Enumeration<URL> osgiUrls = _osgiBundleClassLoader.getResources(name); Enumeration<URL> osgiUrls = _osgiBundleClassLoader.getResources(name);
Enumeration<URL> urls = super.getResources(name); Enumeration<URL> urls = super.getResources(name);
if (_lookInOsgiFirst)
{
return Collections.enumeration(toList(osgiUrls, urls)); return Collections.enumeration(toList(osgiUrls, urls));
} }
else
{
return Collections.enumeration(toList(urls, osgiUrls));
}
}
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
@Override @Override
protected Class<?> findClass(String name) throws ClassNotFoundException protected Class<?> findClass(String name) throws ClassNotFoundException
{ {
try return _osgiBundleClassLoader.loadClass(name);
{
return _lookInOsgiFirst ? _osgiBundleClassLoader.loadClass(name) : super.findClass(name);
}
catch (ClassNotFoundException cne)
{
try
{
return _lookInOsgiFirst ? super.findClass(name) : _osgiBundleClassLoader.loadClass(name);
}
catch (ClassNotFoundException cne2)
{
throw cne;
}
}
} }