In RMI, I can only get return value by
InetSocketAddress address = new InetSocketAddress(hostname, port);
Server server = Stub.create(Server.class, address);
int return = server.getValue();
But, I can't get it by
public class Return {
int value;
}
InetSocketAddress address = new InetSocketAddress(hostname, port);
Server server = Stub.create(Server.class, address);
Return return = new Return();
server.getValue(return);
I know arguments will be serialized and deserialized, but that's not my question, my question is "why can't Java emulate a pass-by-reference as a pass by in-out, as was done in C with RPC?", I think it's related to java environment. By in-out I mean in C with RPC, you can get return value by
int return;
rpc.getValue(&return);
Hope now my question is clear.
Returning additional object proxies would pose an implementation challenge. As things stand, there's only one way to create a remote object. if methods are allowed to spawn more remote objects just by returning regular objects, then all those calls need to be intercepted, objects properly catalogued, etc.
In other words, the Java people - unlike , e. g. DCOM people - decided not to do the extra plumbing. And that will always be the answer to the "why is system A unlike system B" quesions.