public Object invoke(Remote obj,java.lang.reflect.Method method,Object[] params,long opnum) throws Exception {
  boolean force=false;
  RemoteRef localRef;
  Exception exception=null;
synchronized (this) {
    if (ref == null) {
      localRef=activate(force);
      force=true;
    }
 else {
      localRef=ref;
    }
  }
  for (int retries=MAX_RETRIES; retries > 0; retries--) {
    try {
      return localRef.invoke(obj,method,params,opnum);
    }
 catch (    NoSuchObjectException e) {
      exception=e;
    }
catch (    ConnectException e) {
      exception=e;
    }
catch (    UnknownHostException e) {
      exception=e;
    }
catch (    ConnectIOException e) {
      exception=e;
    }
catch (    MarshalException e) {
      throw e;
    }
catch (    ServerError e) {
      throw e;
    }
catch (    ServerException e) {
      throw e;
    }
catch (    RemoteException e) {
synchronized (this) {
        if (localRef == ref) {
          ref=null;
        }
      }
      throw e;
    }
    if (retries > 1) {
synchronized (this) {
        if (localRef.remoteEquals(ref) || ref == null) {
          RemoteRef newRef=activate(force);
          if (newRef.remoteEquals(localRef) && exception instanceof NoSuchObjectException && force == false) {
            newRef=activate(true);
          }
          localRef=newRef;
          force=true;
        }
 else {
          localRef=ref;
          force=false;
        }
      }
    }
  }
  throw exception;
}

public Object invoke ( Remote obj , java . lang . reflect . Method method , Object [ ] params , long opnum ) throws Exception { boolean force = false ; RemoteRef localRef ; Exception exception = null ; synchronized ( this ) { if ( ref == null ) { localRef = activate ( force ) ; force = true ; } else { localRef = ref ; } } for ( int retries = MAX_RETRIES ; retries > 0 ; retries -- ) { try { return localRef . invoke ( obj , method , params , opnum ) ; } catch ( NoSuchObjectException e ) { exception = e ; } catch ( ConnectException e ) { exception = e ; } catch ( UnknownHostException e ) { exception = e ; } catch ( ConnectIOException e ) { exception = e ; } catch ( MarshalException e ) { throw e ; } catch ( ServerError e ) { throw e ; } catch ( ServerException e ) { throw e ; } catch ( RemoteException e ) { synchronized ( this ) { if ( localRef == ref ) { ref = null ; } } throw e ; } if ( retries > 1 ) { synchronized ( this ) { if ( localRef . remoteEquals ( ref ) || ref == null ) { RemoteRef newRef = activate ( force ) ; if ( newRef . remoteEquals ( localRef ) && exception instanceof NoSuchObjectException && force == false ) { newRef = activate ( true ) ; } localRef = newRef ; force = true ; } else { localRef = ref ; force = false ; } } } } throw exception ; }
invoke method on remote object . this method delegates remote method invocation to the underlying ref type . if the underlying reference is not known ( is null ) , then the object must be activated first . if an attempt at method invocation fails , the object should force reactivation . method invocation must preserve " at most once " call semantics . in rmi , " at most once " applies to parameter deserialization at the remote site and the remote object ' s method execution . " at most once " does not apply to parameter serialization at the client so the parameters of a call don ' t need to be buffered in anticipation of call retry . thus , a method call is only be retried if the initial method invocation does not execute at all at the server ( including parameter deserialization ) .
