else { throw new Error("The remote method threw a java.lang.Throwable that is neither java.lang.Exception nor java.lang.Error.", e);
else { throw new Error( "The remote method threw a java.lang.Throwable that"+ " is neither java.lang.Exception nor java.lang.Error.", e);
public Object incomingMessageCall(UnicastConnection conn, int method, long hash) throws Exception {//System.out.println("method = " + method + ", hash = " + hash);	// If method is -1 then this is JDK 1.2 RMI - so use the hash	// to locate the method	if (method == -1) {		Method meth = (Method)methods.get(new Long (hash));//System.out.println("class = " + myself.getClass() + ", meth = " + meth);		if (meth == null) {			throw new NoSuchMethodException();		}		ObjectInputStream in = conn.getObjectInputStream();		int nrargs = meth.getParameterTypes().length;		Object[] args = new Object[nrargs];		for (int i = 0; i < nrargs; i++) {			/** 			 * For debugging purposes - we don't handle CodeBases			 * quite right so we don't always find the stubs.  This			 * lets us know that.			 */			try {				// need to handle primitive types				args[i] = ((RMIObjectInputStream)in).readValue(meth.getParameterTypes()[i]);							}			catch (Exception t) {				t.printStackTrace();				throw t;			}		}		//We must reinterpret the exception thrown by meth.invoke()		//return (meth.invoke(myself, args));		Object ret = null;		try{		    ret = meth.invoke(myself, args);		}catch(InvocationTargetException e){                    Throwable cause = e.getTargetException();                    if (cause instanceof Exception) {                        throw (Exception)cause;                    }                    else if (cause instanceof Error) {                        throw (Error)cause;                    }                    else {                        throw new Error("The remote method threw a java.lang.Throwable that is neither java.lang.Exception nor java.lang.Error.", e);                    }		}		return ret;	}	// Otherwise this is JDK 1.1 style RMI - we find the skeleton	// and invoke it using the method number.  We wrap up our	// connection system in a UnicastRemoteCall so it appears in a	// way the Skeleton can handle.	else {		if (skel == null) {			throw new NoSuchMethodException();		}		UnicastRemoteCall call = new UnicastRemoteCall(conn);		skel.dispatch(myself, call, method, hash);		  		if (!call.isReturnValue())		  return RMIVoidValue.INSTANCE;		else		  return (call.returnValue());	}}