I did some more research on the topic.
Here's a reference. See esp. section 2.6.5
http://java.sun.com/j2se/1.4.2/docs/guide/rmi/spec/rmi-objmodel7.html. This refers to RMI-JRMP.
I assume the question refers to IIOP since this is what the
EJB containers use.
But as I recall, JRMP is pass-by-value and pass-by-reference. RMI-IIOP also supports both.
Stubs must be passed over the network. What happens when you use JNDI to look up a home interface? You, the client, are getting a stub. Also, the client can have a reference to a stub. You can pass this stub around just like anyother object.
Now that I think about it there are several cases to consider. Assume you have a remote method "void doSomething(Object z) throws RemoteException"
You, the client, calls doSomething and pass in an object z. I'll take an educated guess at the result: I haven't actually tried out all these scenarios. Let me know if something is inaccurate.
1) The class of z does not implement Serializable or Remote. Result: runtime exception.
2) The class of z does implement Serializable but not Remote. Result: z is packaged into a stream of bytes and sent over the wire to the remote object.
3) The class of z implements Remote, but is not Serializable. Futhermore, z has been exported as a remote object in this JVM. Result: a stub is created by the rmi runtime and sent over the wire.
4) The class of z implements Remote, but is not Serializable. Futhermore, z has NOT been exported as a remote object in this JVM. Result: a runtime error?
5) The class of z implements RemoteStub. Result: z is Serialzed and sent over the wire. If it implements RemoteStub then it is a stub object, which is Serializable.
The following scenario is why the original question is misleading:
6) The class of z implements both Serializable and Remote.
6a) z has been exported by to the rmi runtime. Result:
Send stub over wire.
6b) z has NOT been exported to the rmi runtime. Result: z is
itself serialized and sent over the wire.