Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where has sun.misc.Perf moved now that tools.jar was decomposed in Java 9

sun.misc.Perf was in tools.jar and in Java 9 this was removed and restructured based on the modules concept, so the question is how do you access it in newer Java? I need to know which module now contains this code.

like image 967
Alexandros Avatar asked Jul 31 '18 23:07

Alexandros


1 Answers

The implementation has been moved under the jdk.internal.perf package within the java.base module.

As the name already suggests, the package has not been exported from the module and hence if you still want to explicitly make use of the classes within this package, you can make use of the VM option:

--add-exports java.base/jdk.internal.perf=<your-module-name>

Do note though, this is an unreliable way of making use of such classes and a better solution would always be to migrate for the specific use cases without depending on the (internal) sun.misc.* classes.

like image 65
Naman Avatar answered Oct 19 '22 03:10

Naman