private static Object newProxyInstance(List<ClassLoader> classLoadersToTry,Class<?>[] interfaces,InvocationHandler delegate) throws IllegalArgumentException {
  Object ret=null;
  ClassLoader cl=classLoadersToTry.get(0);
  List<ClassLoader> remainingClassLoaders=classLoadersToTry.subList(1,classLoadersToTry.size());
  try {
    return Proxy.newProxyInstance(cl,interfaces,delegate);
  }
 catch (  IllegalArgumentException someClassNotFound) {
    if (remainingClassLoaders.size() > 0) {
      ret=newProxyInstance(remainingClassLoaders,interfaces,delegate);
    }
 else {
      throw someClassNotFound;
    }
  }
  return ret;
}

private static Object newProxyInstance ( List < ClassLoader > classLoadersToTry , Class < ? > [ ] interfaces , InvocationHandler delegate ) throws IllegalArgumentException { Object ret = null ; ClassLoader cl = classLoadersToTry . get ( 0 ) ; List < ClassLoader > remainingClassLoaders = classLoadersToTry . subList ( 1 , classLoadersToTry . size ( ) ) ; try { return Proxy . newProxyInstance ( cl , interfaces , delegate ) ; } catch ( IllegalArgumentException someClassNotFound ) { if ( remainingClassLoaders . size ( ) > 0 ) { ret = newProxyInstance ( remainingClassLoaders , interfaces , delegate ) ; } else { throw someClassNotFound ; } } return ret ; }
creates a new dynamic proxy instance for the given delegate .
