Search code examples
javastaticrmi

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?


Solution

  • 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.