public void dispatch(Remote obj,RemoteCall call) throws IOException {
  int num;
  long op;
  try {
    ObjectInput in;
    try {
      in=call.getInputStream();
      num=in.readInt();
      if (num >= 0) {
        if (skel != null) {
          oldDispatch(obj,call,num);
          return;
        }
 else {
          throw new UnmarshalException("skeleton class not found but required " + "for client version");
        }
      }
      op=in.readLong();
    }
 catch (    Exception readEx) {
      throw new UnmarshalException("error unmarshalling call header",readEx);
    }
    MarshalInputStream marshalStream=(MarshalInputStream)in;
    marshalStream.skipDefaultResolveClass();
    Method method=hashToMethod_Map.get(op);
    if (method == null) {
      throw new UnmarshalException("unrecognized method hash: " + "method not supported by remote object");
    }
    logCall(obj,method);
    Object[] params=null;
    try {
      unmarshalCustomCallData(in);
      params=unmarshalParameters(obj,method,marshalStream);
    }
 catch (    java.io.IOException e) {
      throw new UnmarshalException("error unmarshalling arguments",e);
    }
catch (    ClassNotFoundException e) {
      throw new UnmarshalException("error unmarshalling arguments",e);
    }
 finally {
      call.releaseInputStream();
    }
    Object result;
    try {
      result=method.invoke(obj,params);
    }
 catch (    InvocationTargetException e) {
      throw e.getTargetException();
    }
    try {
      ObjectOutput out=call.getResultStream(true);
      Class<?> rtype=method.getReturnType();
      if (rtype != void.class) {
        marshalValue(rtype,result,out);
      }
    }
 catch (    IOException ex) {
      throw new MarshalException("error marshalling return",ex);
    }
  }
 catch (  Throwable e) {
    logCallException(e);
    ObjectOutput out=call.getResultStream(false);
    if (e instanceof Error) {
      e=new ServerError("Error occurred in server thread",(Error)e);
    }
 else     if (e instanceof RemoteException) {
      e=new ServerException("RemoteException occurred in server thread",(Exception)e);
    }
    if (suppressStackTraces) {
      clearStackTraces(e);
    }
    out.writeObject(e);
  }
 finally {
    call.releaseInputStream();
    call.releaseOutputStream();
  }
}

public void dispatch ( Remote obj , RemoteCall call ) throws IOException { int num ; long op ; try { ObjectInput in ; try { in = call . getInputStream ( ) ; num = in . readInt ( ) ; if ( num >= 0 ) { if ( skel != null ) { oldDispatch ( obj , call , num ) ; return ; } else { throw new UnmarshalException ( "skeleton class not found but required " + "for client version" ) ; } } op = in . readLong ( ) ; } catch ( Exception readEx ) { throw new UnmarshalException ( "error unmarshalling call header" , readEx ) ; } MarshalInputStream marshalStream = ( MarshalInputStream ) in ; marshalStream . skipDefaultResolveClass ( ) ; Method method = hashToMethod_Map . get ( op ) ; if ( method == null ) { throw new UnmarshalException ( "unrecognized method hash: " + "method not supported by remote object" ) ; } logCall ( obj , method ) ; Object [ ] params = null ; try { unmarshalCustomCallData ( in ) ; params = unmarshalParameters ( obj , method , marshalStream ) ; } catch ( java . io . IOException e ) { throw new UnmarshalException ( "error unmarshalling arguments" , e ) ; } catch ( ClassNotFoundException e ) { throw new UnmarshalException ( "error unmarshalling arguments" , e ) ; } finally { call . releaseInputStream ( ) ; } Object result ; try { result = method . invoke ( obj , params ) ; } catch ( InvocationTargetException e ) { throw e . getTargetException ( ) ; } try { ObjectOutput out = call . getResultStream ( true ) ; Class < ? > rtype = method . getReturnType ( ) ; if ( rtype != void . class ) { marshalValue ( rtype , result , out ) ; } } catch ( IOException ex ) { throw new MarshalException ( "error marshalling return" , ex ) ; } } catch ( Throwable e ) { logCallException ( e ) ; ObjectOutput out = call . getResultStream ( false ) ; if ( e instanceof Error ) { e = new ServerError ( "Error occurred in server thread" , ( Error ) e ) ; } else if ( e instanceof RemoteException ) { e = new ServerException ( "RemoteException occurred in server thread" , ( Exception ) e ) ; } if ( suppressStackTraces ) { clearStackTraces ( e ) ; } out . writeObject ( e ) ; } finally { call . releaseInputStream ( ) ; call . releaseOutputStream ( ) ; } }
call to dispatch to the remote object ( on the server side ) . the up - call to the server and the marshalling of return result ( or exception ) should be handled before returning from this method .
