简体   繁体   中英

No RMI for Java static methods

RMI, Remote Method Invocation, works only on Java object methods. In order to make an object remoteable, it has to be exported for stub generation, bind to a rmiregistry, and so on.

And on the user side the object has to be look up and so on. The whole instantiation process is needed in oder to realize RMI for a Java object.

But why are Java static methods not enabled to be invoked remotely? Are there reasons, which would have been critical to the semantic, that Java classes/static methods are not remoteable?

RMI uses Java interfaces to describe remote operations. Static methods can't be expressed via interfaces, and therefore cannot be remoted. That's the way it was designed.

If you need to access static methods via RMI, you need to wrap them in something that can be exported.

Java接口不支持静态方法,要使用RMI调用对象,它必须实现和接口,然后将其作为服务公开在RMI注册表中。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM