-1

I'm currently using Java 8 and want to migrate to Java 11.

The jdeps -P -jdkinternals ... command listed below classes as not supported from Java 10.

sun.rmi.server.UnicastRef
sun.rmi.server.UnicastRef2 
sun.rmi.transport.Endpoint 
sun.rmi.transport.LiveRef 
sun.rmi.transport.tcp.TCPEndpoint 

Can someone please help me out in searching the alternatives for the above listed classes?

Output of JDEPS in JDK 11:

digraph "AppCore.jar" {
// Path: D:\jdeps\srclib\AppCore.jar
   "com.util.RMIServer"                                -> "sun.rmi.server.UnicastRef (JDK internal API (java.rmi))";
   "com.util.RMIServer"                                -> "sun.rmi.server.UnicastRef2 (JDK internal API (java.rmi))";
   "com.util.RMIServer"                                -> "sun.rmi.transport.Endpoint (JDK internal API (java.rmi))";
   "com.util.RMIServer"                                -> "sun.rmi.transport.LiveRef (JDK internal API (java.rmi))";
   "com.util.RMIServer"                                -> "sun.rmi.transport.tcp.TCPEndpoint (JDK internal API (java.rmi))";
   "com.util.WrappedPostlessSocket"                    -> "sun.rmi.transport.proxy.RMISocketInfo (JDK internal API (JDK removed internal API))";
}

Thanks.

Rohit Gaikwad
  • 3,677
  • 3
  • 17
  • 40
  • Why? You don't use these classes directly. – user207421 Jun 13 '18 at 00:36
  • @EJP. The Class files like sun.rmi.server.UnicastRef do exists in java 10, But the jdeps digraph shows that the jar does use some JDK internal packages. I've now added the ...jar.dot output in the Question. – Rohit Gaikwad Jun 13 '18 at 06:50
  • 1
    If *your* application uses these classes *directly*, there is something wrong with it and you need to fix it. Java itself is allowed to use these classes. – user207421 Jun 13 '18 at 07:33
  • 1
    @Tschallacka Yes, I looked at the package name, and it is `java.rmi.registry`, and it is specifically mentioned on that page as having been there since Java 1.1, and this is not one of the packages mentioned by the OP, and the package `java.rmi.server` you mentioned has also been there since Java 1.1, and the packages `java.rmi.transport` and `java.rmi.transport.tcp` you invented do not exist in any version of Java at all. Your point? – user207421 Jun 13 '18 at 07:37
  • @EJB, The App is using the classes directly. There is nothing wrong till java 8. As the migration to java 11 shows me usage of internals. An alternative for these classes needs to be figured out. – Rohit Gaikwad Jun 13 '18 at 10:22
  • 1
    It was *always* wrong to use `sun.*` classes directly, and there has been a specific warning about this issue for over twenty years. Post the code concerned and we will tell you how to fix it. – user207421 Jun 13 '18 at 10:40
  • 1
    See ['Why developers should not write programs that call `sun.*` packages](http://www.oracle.com/technetwork/java/faq-sun-packages-142232.html), and [this question](https://stackoverflow.com/q/1834826/207421), and many others. – user207421 Jun 14 '18 at 02:33
  • @EJB, I understand this. But, the App was developed more than 10+ years back, it is currently using Java 8. I'm now working on migration of the App to Java 11. For this I'm looking for an alternative solution. – Rohit Gaikwad Jun 14 '18 at 03:02
  • 1
    You'll have to fix it. Looks like it is confined to just a couple of classes. – user207421 Jun 14 '18 at 04:48

1 Answers1

1

JDK 11 allows us to make use of few Internal APIs by exporting the module in a project with a warning like below:

warning: UnicastRef is internal proprietary API and may be removed in a future release.

The warning clearly states that what is going to happen.

Command:

javac --add-exports java.rmi/sun.rmi.server=ALL-UNNAMED RMIServer.java  

Where, java.rmi -> is a module name,
       sun.rmi.server -> is the package name,
       RMIServer.java -> Class in which package sun.rmi.server is imported.

There are few other internal APIs that are moved to jdk.internal...* packages in java 9, which can be accessed without any warning as below:

javac --add -exports jdk.management.agent/jdk.internal.agent=ALL-UNNAMED HelloWorld.java  

Note: This question is not related to whether to make use of internal API directly in your application code. As there are software products developed using internal APIs 15+ years back and still they exists in java 8.

Rohit Gaikwad
  • 3,677
  • 3
  • 17
  • 40