Deallocate direct NIO buffers
Julien Gouesse
gouessej at yahoo.fr
Fri Aug 5 17:16:20 UTC 2016
Now I get this exception when I run my code:
août 05, 2016 7:09:19 PM engine.misc.DeallocationHelper$OracleSunOpenJdkDeallocator run
AVERTISSEMENT: The deallocation of a direct NIO buffer has failed
java.lang.IllegalAccessException: class engine.misc.DeallocationHelper$OracleSunOpenJdkDeallocator cannot access class jdk.internal.ref.Cleaner (in module java.base) because module java.base does not export jdk.internal.ref to unnamed module @464bee09
at jdk.internal.reflect.Reflection.throwIllegalAccessException(java.base at 9-ea/Reflection.java:405)
at jdk.internal.reflect.Reflection.throwIllegalAccessException(java.base at 9-ea/Reflection.java:396)
at jdk.internal.reflect.Reflection.ensureMemberAccess(java.base at 9-ea/Reflection.java:98)
at java.lang.reflect.AccessibleObject.slowCheckMemberAccess(java.base at 9-ea/AccessibleObject.java:355)
at java.lang.reflect.AccessibleObject.checkAccess(java.base at 9-ea/AccessibleObject.java:347)
at java.lang.reflect.Method.invoke(java.base at 9-ea/Method.java:527)
at engine.misc.DeallocationHelper$OracleSunOpenJdkDeallocator.run(DeallocationHelper.java:109)
at engine.misc.DeallocationHelper.deallocate(DeallocationHelper.java:729)
at engine.misc.TestDeallocationHelper.main(TestDeallocationHelper.java:137)
I use the following option in command line but it doesn't help:--add-exports jdk.unsupported/jdk.internal.ref=ALL-UNNAMED
Le Vendredi 5 août 2016 14h28, Julien Gouesse <gouessej at yahoo.fr> a écrit :
I'll use this example from Netty:Use reflection to call cleaner on direct byte buffers in JDK9 by varming · Pull Request #5473 · netty/netty
Best regards
| |
| | | | | | | |
| Use reflection to call cleaner on direct byte buffers in...In JDK9 sun.misc.Cleaner is replaced with java.lang.ref.Cleaner$Cleanable, a class with a method void clean() just like the old cleaner. By using a method reference... |
| |
| Afficher sur github.com | Aperçu par Yahoo |
| |
| |
Le Vendredi 5 août 2016 12h01, Julien Gouesse <gouessej at yahoo.fr> a écrit :
Vladimir,
How can I use java.lang.ref.Cleaner with a direct ByteBuffer? I assume that this kind of buffer still uses jdk.internal.ref.Cleaner internally, I wanted to use this cleaner.
Le Vendredi 5 août 2016 7h30, Vladimir Ivanov <vladimir.x.ivanov at oracle.com> a écrit :
Julien,
There is a public API replacement for sun.misc.Cleaner in 9:
java.lang.ref.Cleaner [1]
Best regards,
Vladimir Ivanov
[1] https://bugs.openjdk.java.net/browse/JDK-8138696
On 8/4/16 5:09 AM, Julien Gouesse wrote:
> Hi
> The class sun.misc.Cleaner was moved into the package jdk.internal.ref in the module jdk.unsupported and I have to use a command line switch or another mean to add an export to this module to avoid getting a java.lang.reflect.InaccessibleObjectException. I could use a NativeScope in a source code compatible with Java 1.9 and later but I need to find a solution working both with Java 1.8 and Java 1.9. Christoph Engelbert mentioned the class AutoCleaning here:http://www.slideshare.net/ChristophEngelbert/a-postapocalyptic-sunmiscunsafe-world#94What is the right way to release the native memory allocated by a direct NIO buffer without using any internal API in Java 1.9 and later? I need an explicit mechanism that calls Cleaner.clean() somehow. In which package can I find the class AutoCleaning? Best regards.
>
More information about the panama-dev
mailing list