public Object newProxyInstance(final Class interfce, final InvocationHandler h) throws IllegalArgumentException { try { return Proxy.newProxyInstance(interfce.getClassLoader(), new Class[]{interfce}, h); } catch (final IllegalArgumentException iae) { final ClassLoader reconciliatedCl = reconciliate(interfce); try { reconciliatedCl.loadClass(interfce.getName()); return Proxy.newProxyInstance(reconciliatedCl, new Class[]{interfce}, h); } catch (final ClassNotFoundException e2) { throw iae; } } }
public Object newProxyInstance(final Class interfce, final InvocationHandler h) throws IllegalArgumentException { try { return Proxy.newProxyInstance(interfce.getClassLoader(), new Class[]{interfce}, h); } catch (final IllegalArgumentException iae) { final ClassLoader reconciliatedCl = reconciliate(interfce); try { reconciliatedCl.loadClass(interfce.getName()); return Proxy.newProxyInstance(reconciliatedCl, new Class[]{interfce}, h); } catch (final ClassNotFoundException e2) { throw iae; } } }
public Object newProxyInstance(final Class[] interfaces, final InvocationHandler handler) throws IllegalArgumentException { if (interfaces.length < 1) { throw new IllegalArgumentException("It's boring to implement 0 interfaces!"); } try { return Proxy.newProxyInstance(interfaces[0].getClassLoader(), interfaces, handler); } catch (final IllegalArgumentException e) { final ClassLoader tccl = Thread.currentThread().getContextClassLoader(); try { final Class tcclHomeClass = tccl.loadClass(interfaces[0].getName()); if (tcclHomeClass == interfaces[0]) { return Proxy.newProxyInstance(tccl, interfaces, handler); } } catch (final ClassNotFoundException e1) { // maybe all interfaces are not in the same classloader (OSGi) // trying to reconciliate it here final ClassLoader reconciliatedCl = reconciliate(interfaces); final Class homeClass; try { homeClass = reconciliatedCl.loadClass(interfaces[0].getName()); if (homeClass == interfaces[0]) { return Proxy.newProxyInstance(reconciliatedCl, interfaces, handler); } } catch (final ClassNotFoundException e2) { throw e; } } throw e; } }
public Object newProxyInstance(final Class[] interfaces, final InvocationHandler handler) throws IllegalArgumentException { if (interfaces.length < 1) { throw new IllegalArgumentException("It's boring to implement 0 interfaces!"); } try { return Proxy.newProxyInstance(interfaces[0].getClassLoader(), interfaces, handler); } catch (final IllegalArgumentException e) { final ClassLoader tccl = Thread.currentThread().getContextClassLoader(); try { final Class tcclHomeClass = tccl.loadClass(interfaces[0].getName()); if (tcclHomeClass == interfaces[0]) { return Proxy.newProxyInstance(tccl, interfaces, handler); } } catch (final ClassNotFoundException e1) { // maybe all interfaces are not in the same classloader (OSGi) // trying to reconciliate it here final ClassLoader reconciliatedCl = reconciliate(interfaces); final Class homeClass; try { homeClass = reconciliatedCl.loadClass(interfaces[0].getName()); if (homeClass == interfaces[0]) { return Proxy.newProxyInstance(reconciliatedCl, interfaces, handler); } } catch (final ClassNotFoundException e2) { throw e; } } throw e; } }