1
votes

Without having any experience with Java RMI, I have a naive question, but am still not sure about the answer after searching the internet.

Question:

To me, there are two scenarios:

Scenario-1: Start a Java program from local, during its execution, it calls a method from a class stored on a remote machine, then the class of that method would be downloaded to the local machine, and resume executing.

Scenario-2: Start a Java program from local, during its execution, it calls a method from a class stored on a remote machine, then that method will be executed on the remote machine, and the results will be sent back to the local machine. (Does this require class/object transfer?)

Which one does Java RMI use? or neither?

From Wikipedia of RPC: "RPC allows a computer program to cause a subroutine or procedure to execute in another address space (commonly on another computer on a shared network)", it seems it is the 2nd scenario.

But according to this paper Reducing Data Transfer during Remote Classloading in Java RMI, it seems it is the 1st scenario.

2
What part of the linked paper make you think it is Scenario #2?Stephen C
@StephenCSThe linked paper make me think it is Scenario #1, as it mentions remote classloading (to me, loading a remote class to local).JackWM
Remote class loading does not mean that. It means loading the classes (the code) from a location that is remote to the location where the code is going to be run. The code moves to the RMI target object ... not vice versa.Stephen C
@StephenC By this "The code moves to the RMI target object", do you mean the code is moved to the remote machine in RMI case?JackWM

2 Answers

1
votes

When using RMI, you basically have an interface which is shared between a client and the server. Server must have an implementation and the client should not have this implementation. So there is no class loading or any sort of client-to-server logic transfer, client is totally unaware of the server interface implementation.

RMI serializes and transports method parameters, then the server logic is being executed, the result is serialized and transported back to client.

0
votes

The method will be executed on the remote machine. For this to work, the local machine downloads a class that wraps the communication between the local machine and the remote machine.