What really gets passed when you pass an object to a remote method?

If your remote method has an argument that’s an object type, the argument is passed as a full copy of the object itself!
For remote calls, Java passes objects by object copy, not reference copy.
A serialized copy of the object is shipped to the Remote object.

Getting the object argument from the client to the server
Client invokes trainPet(myDog) on the stub, passing a copy of the reference to the Dog object.

The stub makes a serialized copy of the object and sends that copy over the wire to the skeleton.

Unpacking (deserializing) the object on the server
The skeleton deserializes the passed argument, creating a new Dog object in the Remote object’s heap.

The skeleton invokes the method on the Remote object, passing a plain old Java reference to the new Dog object.

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access