Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaLangAccess and SharedSecrets in Java 9

Tags:

java

java-9

It seems like the SharedSecrets and JavaLangAccess classes from the sun.misc package were removed in Java 9.

Are there any replacements in Java 9 for the functionality provided by these classes?

like image 317
Clashsoft Avatar asked Oct 06 '17 19:10

Clashsoft


2 Answers

Both the above classes are packaged in jdk.internal.misc package.

One way you can try and access them is by using the option

--add-exports <source-module>/<package>=<target-module>(,<target-module>)*

for your use case as :

--add-exports java.base/jdk.internal.misc=your.module

Note:- Disclaimer from JEP-261:Module System -

The --add-exports and --add-opens options must be used with great care. You can use them to gain access to an internal API of a library module, or even of the JDK itself, but you do so at your own risk: If that internal API is changed or removed then your library or application will fail.

like image 154
Naman Avatar answered Sep 21 '22 09:09

Naman


According to Bug#JDK-8137056

In preparation for JEP 160, SharedSecrets and friend interfaces should be moved out of 'sun.misc' and located in a truly private package

And they are now available at jdk.internal.misc

Move SharedSecrets and friends to jdk.internal.misc

like image 21
Ravi Avatar answered Sep 18 '22 09:09

Ravi