@Test public void testLoadClassFromBothOSGiAndParentParentException() throws ClassNotFoundException { String testName = "testName"; when( parentClassLoader.loadClass( testName, false ) ).thenThrow( new RuntimeException() ); when( bundleWiringClassloader.loadClass( testName, false ) ).thenReturn( (Class) PluginRegistry.class ); assertEquals( PluginRegistry.class, shimBridgingClassloader.loadClass( testName ) ); }
@Override public Class<?> loadClass( String name, boolean resolve ) throws ClassNotFoundException { Class<?> result = null; synchronized ( this ) { result = findLoadedClass( name ); } if ( result == null ) { try { result = findClass( name ); } catch ( Exception e ) { } } if ( result == null ) { try { Class<?> osgiProvidedClass = bundleWiringClassloader.loadClass( name, resolve ); if ( osgiProvidedClass.getClassLoader() == PluginRegistry.class.getClassLoader() ) { try { return super.loadClass( name, resolve ); } catch ( Exception e ) { } } return osgiProvidedClass; } catch ( Exception e ) { } } if ( result == null ) { return super.loadClass( name, resolve ); } if ( resolve ) { resolveClass( result ); } return result; }
ShimBridgingClassloader extends ClassLoader implements BundleReference { @Override public Class<?> loadClass( String name, boolean resolve ) throws ClassNotFoundException { Class<?> result = null; synchronized ( this ) { result = findLoadedClass( name ); } if ( result == null ) { try { result = findClass( name ); } catch ( Exception e ) { } } if ( result == null ) { try { Class<?> osgiProvidedClass = bundleWiringClassloader.loadClass( name, resolve ); if ( osgiProvidedClass.getClassLoader() == PluginRegistry.class.getClassLoader() ) { try { return super.loadClass( name, resolve ); } catch ( Exception e ) { } } return osgiProvidedClass; } catch ( Exception e ) { } } if ( result == null ) { return super.loadClass( name, resolve ); } if ( resolve ) { resolveClass( result ); } return result; } }
ShimBridgingClassloader extends ClassLoader implements BundleReference { @Override public Class<?> loadClass( String name, boolean resolve ) throws ClassNotFoundException { Class<?> result = null; synchronized ( this ) { result = findLoadedClass( name ); } if ( result == null ) { try { result = findClass( name ); } catch ( Exception e ) { } } if ( result == null ) { try { Class<?> osgiProvidedClass = bundleWiringClassloader.loadClass( name, resolve ); if ( osgiProvidedClass.getClassLoader() == PluginRegistry.class.getClassLoader() ) { try { return super.loadClass( name, resolve ); } catch ( Exception e ) { } } return osgiProvidedClass; } catch ( Exception e ) { } } if ( result == null ) { return super.loadClass( name, resolve ); } if ( resolve ) { resolveClass( result ); } return result; } ShimBridgingClassloader( ClassLoader parentClassLoader, BundleContext bundleContext ); }
ShimBridgingClassloader extends ClassLoader implements BundleReference { @Override public Class<?> loadClass( String name, boolean resolve ) throws ClassNotFoundException { Class<?> result = null; synchronized ( this ) { result = findLoadedClass( name ); } if ( result == null ) { try { result = findClass( name ); } catch ( Exception e ) { } } if ( result == null ) { try { Class<?> osgiProvidedClass = bundleWiringClassloader.loadClass( name, resolve ); if ( osgiProvidedClass.getClassLoader() == PluginRegistry.class.getClassLoader() ) { try { return super.loadClass( name, resolve ); } catch ( Exception e ) { } } return osgiProvidedClass; } catch ( Exception e ) { } } if ( result == null ) { return super.loadClass( name, resolve ); } if ( resolve ) { resolveClass( result ); } return result; } ShimBridgingClassloader( ClassLoader parentClassLoader, BundleContext bundleContext ); static Object create( BundleContext bundleContext, String className, List<Object> arguments ); @Override URL getResource( String name ); @Override Class<?> loadClass( String name, boolean resolve ); @Override Bundle getBundle(); }
ShimBridgingClassloader extends ClassLoader implements BundleReference { @Override public Class<?> loadClass( String name, boolean resolve ) throws ClassNotFoundException { Class<?> result = null; synchronized ( this ) { result = findLoadedClass( name ); } if ( result == null ) { try { result = findClass( name ); } catch ( Exception e ) { } } if ( result == null ) { try { Class<?> osgiProvidedClass = bundleWiringClassloader.loadClass( name, resolve ); if ( osgiProvidedClass.getClassLoader() == PluginRegistry.class.getClassLoader() ) { try { return super.loadClass( name, resolve ); } catch ( Exception e ) { } } return osgiProvidedClass; } catch ( Exception e ) { } } if ( result == null ) { return super.loadClass( name, resolve ); } if ( resolve ) { resolveClass( result ); } return result; } ShimBridgingClassloader( ClassLoader parentClassLoader, BundleContext bundleContext ); static Object create( BundleContext bundleContext, String className, List<Object> arguments ); @Override URL getResource( String name ); @Override Class<?> loadClass( String name, boolean resolve ); @Override Bundle getBundle(); static final String HADOOP_SPOON_PLUGIN; }