public static Class<?> loadProxyClass(String codebase,String[] interfaces,ClassLoader defaultLoader) throws MalformedURLException, ClassNotFoundException {
  if (loaderLog.isLoggable(Log.BRIEF)) {
    loaderLog.log(Log.BRIEF,"interfaces = " + Arrays.asList(interfaces) + ", "+ "codebase = \""+ (codebase != null ? codebase : "")+ "\""+ (defaultLoader != null ? ", defaultLoader = " + defaultLoader : ""));
  }
  ClassLoader parent=getRMIContextClassLoader();
  if (loaderLog.isLoggable(Log.VERBOSE)) {
    loaderLog.log(Log.VERBOSE,"(thread context class loader: " + parent + ")");
  }
  URL[] urls;
  if (codebase != null) {
    urls=pathToURLs(codebase);
  }
 else {
    urls=getDefaultCodebaseURLs();
  }
  SecurityManager sm=System.getSecurityManager();
  if (sm == null) {
    try {
      Class<?> c=loadProxyClass(interfaces,defaultLoader,parent,false);
      if (loaderLog.isLoggable(Log.VERBOSE)) {
        loaderLog.log(Log.VERBOSE,"(no security manager: codebase disabled) " + "proxy class defined by " + c.getClassLoader());
      }
      return c;
    }
 catch (    ClassNotFoundException e) {
      if (loaderLog.isLoggable(Log.BRIEF)) {
        loaderLog.log(Log.BRIEF,"(no security manager: codebase disabled) " + "proxy class resolution failed",e);
      }
      throw new ClassNotFoundException(e.getMessage() + " (no security manager: RMI class loader disabled)",e.getException());
    }
  }
  Loader loader=lookupLoader(urls,parent);
  try {
    if (loader != null) {
      loader.checkPermissions();
    }
  }
 catch (  SecurityException e) {
    try {
      Class<?> c=loadProxyClass(interfaces,defaultLoader,parent,false);
      if (loaderLog.isLoggable(Log.VERBOSE)) {
        loaderLog.log(Log.VERBOSE,"(access to codebase denied) " + "proxy class defined by " + c.getClassLoader());
      }
      return c;
    }
 catch (    ClassNotFoundException unimportant) {
      if (loaderLog.isLoggable(Log.BRIEF)) {
        loaderLog.log(Log.BRIEF,"(access to codebase denied) " + "proxy class resolution failed",e);
      }
      throw new ClassNotFoundException("access to class loader denied",e);
    }
  }
  try {
    Class<?> c=loadProxyClass(interfaces,defaultLoader,loader,true);
    if (loaderLog.isLoggable(Log.VERBOSE)) {
      loaderLog.log(Log.VERBOSE,"proxy class defined by " + c.getClassLoader());
    }
    return c;
  }
 catch (  ClassNotFoundException e) {
    if (loaderLog.isLoggable(Log.BRIEF)) {
      loaderLog.log(Log.BRIEF,"proxy class resolution failed",e);
    }
    throw e;
  }
}

public static Class < ? > loadProxyClass ( String codebase , String [ ] interfaces , ClassLoader defaultLoader ) throws MalformedURLException , ClassNotFoundException { if ( loaderLog . isLoggable ( Log . BRIEF ) ) { loaderLog . log ( Log . BRIEF , "interfaces = " + Arrays . asList ( interfaces ) + ", " + "codebase = \"" + ( codebase != null ? codebase : "" ) + "\"" + ( defaultLoader != null ? ", defaultLoader = " + defaultLoader : "" ) ) ; } ClassLoader parent = getRMIContextClassLoader ( ) ; if ( loaderLog . isLoggable ( Log . VERBOSE ) ) { loaderLog . log ( Log . VERBOSE , "(thread context class loader: " + parent + ")" ) ; } URL [ ] urls ; if ( codebase != null ) { urls = pathToURLs ( codebase ) ; } else { urls = getDefaultCodebaseURLs ( ) ; } SecurityManager sm = System . getSecurityManager ( ) ; if ( sm == null ) { try { Class < ? > c = loadProxyClass ( interfaces , defaultLoader , parent , false ) ; if ( loaderLog . isLoggable ( Log . VERBOSE ) ) { loaderLog . log ( Log . VERBOSE , "(no security manager: codebase disabled) " + "proxy class defined by " + c . getClassLoader ( ) ) ; } return c ; } catch ( ClassNotFoundException e ) { if ( loaderLog . isLoggable ( Log . BRIEF ) ) { loaderLog . log ( Log . BRIEF , "(no security manager: codebase disabled) " + "proxy class resolution failed" , e ) ; } throw new ClassNotFoundException ( e . getMessage ( ) + " (no security manager: RMI class loader disabled)" , e . getException ( ) ) ; } } Loader loader = lookupLoader ( urls , parent ) ; try { if ( loader != null ) { loader . checkPermissions ( ) ; } } catch ( SecurityException e ) { try { Class < ? > c = loadProxyClass ( interfaces , defaultLoader , parent , false ) ; if ( loaderLog . isLoggable ( Log . VERBOSE ) ) { loaderLog . log ( Log . VERBOSE , "(access to codebase denied) " + "proxy class defined by " + c . getClassLoader ( ) ) ; } return c ; } catch ( ClassNotFoundException unimportant ) { if ( loaderLog . isLoggable ( Log . BRIEF ) ) { loaderLog . log ( Log . BRIEF , "(access to codebase denied) " + "proxy class resolution failed" , e ) ; } throw new ClassNotFoundException ( "access to class loader denied" , e ) ; } } try { Class < ? > c = loadProxyClass ( interfaces , defaultLoader , loader , true ) ; if ( loaderLog . isLoggable ( Log . VERBOSE ) ) { loaderLog . log ( Log . VERBOSE , "proxy class defined by " + c . getClassLoader ( ) ) ; } return c ; } catch ( ClassNotFoundException e ) { if ( loaderLog . isLoggable ( Log . BRIEF ) ) { loaderLog . log ( Log . BRIEF , "proxy class resolution failed" , e ) ; } throw e ; } }
define and return a dynamic proxy class in a class loader with urls supplied in the given location . the proxy class will implement interface classes named by the given array of interface names .
