javaadoptopenjdkopenj9

Is Java RMI doesnt work traditional way with AdoptJDK Openj9 JVM?


I am trying to start a simple RMI server with AdoptOpenJDK's OpenJ9 JVM but, the program exits with no error/exception and the RMI server doesn't start. Exact same program works with AdoptOpenJDK's HotSpot JVM and other oracle variants.

Sample code:

   Registry registry = LocateRegistry.createRegistry(9002);
   RMIServer myServerInstance = new RMIServer();
   <<MyClassStub>>stub = <<MyClassStub>> UnicastRemoteObject.exportObject(myServerInstance, 9002);
            registry.rebind("RMIServer", stub);

Solution

  • OpenJ9 open source community contributors confirm that it’s the real issue with OpenJ9. OpenJ9 seems to immediately discard the new server after creating it. When UnicastRemoteObject.exportObject is called, a WeakReference is created and registered to the ReferenceQueue in the reaper. When the exported object is to be destroyed, the reaper checks if there are no more exported objects left to keep track of, then the reaper thread will kill itself, and the VM if there are no other threads keeping it alive.

    Expected this issue to be fixed for -Release 0.24 (Java 8, 11, 15) Jan refresh, Release 0.25 (Java 16)

    Note: For the latest updates keep an eye on https://github.com/eclipse/openj9/issues/10503