Java RMI:为 void 方法阻塞 return?

Java RMI: Blocking for void method return?

我有一个 RMI 接口,它有一个带有 void return 的方法。

例如:

public interface IDummy {
  public void foo() throws RemoteException;
}

然后我通过 UnicastRemoteObject 创建一个存根并导出该存根。

RMI 规范是否要求调用 foo 块直到 foo return 秒? 似乎你必须阻止以防 foo 抛出异常。 即使 return 类型为 void,foo 也可能会抛出异常,因为 RMI 能够传输任意异常。

但是,我听说 RMI 不必为无效 return 案例阻止。

有人有明确的答案吗? 我已经看过 RMI spec and it does not seem to address this issue. Some people 声称它不会阻塞。

此外,我已经阅读了 JDK 源代码,即使 return 值为 void,它也肯定会阻塞。

规范说:

When a stub's method is invoked, it does the following:

  • initiates a connection with the remote JVM containing the remote object,
  • marshals (writes and transmits) the parameters to the remote JVM,
  • waits for the result of the method invocation,
  • unmarshals (reads) the return value or exception returned, and
  • returns the value to the caller.

(强调我的)

所以是的,它必须阻止。

Is it required in the RMI spec that calls to foo block until foo returns

要求所有方法调用阻塞,直到它们return。这里的 RMI 没什么特别的。