private static RemoteStub createStub(Class<?> remoteClass,RemoteRef ref) throws StubNotFoundException {
  String stubname=remoteClass.getName() + "_Stub";
  try {
    Class<?> stubcl=Class.forName(stubname,false,remoteClass.getClassLoader());
    Constructor<?> cons=stubcl.getConstructor(stubConsParamTypes);
    return (RemoteStub)cons.newInstance(new Object[]{ref});
  }
 catch (  ClassNotFoundException e) {
    throw new StubNotFoundException("Stub class not found: " + stubname,e);
  }
catch (  NoSuchMethodException e) {
    throw new StubNotFoundException("Stub class missing constructor: " + stubname,e);
  }
catch (  InstantiationException e) {
    throw new StubNotFoundException("Can't create instance of stub class: " + stubname,e);
  }
catch (  IllegalAccessException e) {
    throw new StubNotFoundException("Stub class constructor not public: " + stubname,e);
  }
catch (  InvocationTargetException e) {
    throw new StubNotFoundException("Exception creating instance of stub class: " + stubname,e);
  }
catch (  ClassCastException e) {
    throw new StubNotFoundException("Stub class not instance of RemoteStub: " + stubname,e);
  }
}

private static RemoteStub createStub ( Class < ? > remoteClass , RemoteRef ref ) throws StubNotFoundException { String stubname = remoteClass . getName ( ) + "_Stub" ; try { Class < ? > stubcl = Class . forName ( stubname , false , remoteClass . getClassLoader ( ) ) ; Constructor < ? > cons = stubcl . getConstructor ( stubConsParamTypes ) ; return ( RemoteStub ) cons . newInstance ( new Object [ ] { ref } ) ; } catch ( ClassNotFoundException e ) { throw new StubNotFoundException ( "Stub class not found: " + stubname , e ) ; } catch ( NoSuchMethodException e ) { throw new StubNotFoundException ( "Stub class missing constructor: " + stubname , e ) ; } catch ( InstantiationException e ) { throw new StubNotFoundException ( "Can't create instance of stub class: " + stubname , e ) ; } catch ( IllegalAccessException e ) { throw new StubNotFoundException ( "Stub class constructor not public: " + stubname , e ) ; } catch ( InvocationTargetException e ) { throw new StubNotFoundException ( "Exception creating instance of stub class: " + stubname , e ) ; } catch ( ClassCastException e ) { throw new StubNotFoundException ( "Stub class not instance of RemoteStub: " + stubname , e ) ; } }
creates a remotestub instance for the specified class , constructed with the specified remoteref . the supplied class must be the most derived class in the remote object ' s superclass chain that implements a remote interface . the stub class name is the name of the specified remoteclass with the suffix " _stub " . the loading of the stub class is initiated from class loader of the specified class ( which may be the bootstrap class loader ) .
