Replace access to sun.misc.VM for JDK 11

General discussion about Universal Media Server (no support or requests)
Post Reply
Posts: 1
Joined: Tue Jun 11, 2019 12:07 am

Replace access to sun.misc.VM for JDK 11

Post by David259 » Tue Jun 11, 2019 12:09 am

In OpenJDK 8, it was possible to access sun.misc.VM and call isDirectMemoryPageAligned and maxDirectMemory.
isDirectMemoryPageAligned is used to size correctly the direct memory to allocate, as done by DirectByteBuffer.
maxDirectMemory is used to report memory statistics as well as access giving the value configured for -XX:MaxDirectMemorySize. Internally, it will set a limit to the allowed consumption of direct memory

Since OpenJDK 9, the class VM has been moved to jdk.internal.misc and is not available unless --add-export java.base/jdk.internal.misc=xyz is used when running the application.

Is there a "right" way to do this ?

Post Reply