Library: https://bintray.com/karlatemp/unsafe-accessor/unsafe-accessor/
Github(outdated): https://github.com/Karlatemp/UnsafeAccessor
How does it work: https://karlatemp.github.io/blog-me/reflect/0.index.html
It uses a much more ingenious method to get Unsafe instance without trigger “WARNING: An illegal reflective access operation has occurred”.
I think it can fix the compatibility issue with java 9+ perfectly.
Just add jcenter to maven repo list and add content below to build.gradle:
implementation 'io.github.karlatemp:unsafe-accessor:1.2.0'
Use io.github.karlatemp.unsafeaccessor.Root.getUnsafe() to get wrapped Unsafe and then call wrappedUnsafe.getUnsafe() to get sun.misc.Unsafe.
It also provides some useful methods like void io.github.karlatemp.unsafeaccessor.Root.setAccessible(AccessibleObject object, boolean isAccessible) and MethodHandles.Lookup io.github.karlatemp.unsafeaccessor.Root.getTrusted().
Thanks for that, I will use it in the project to help increase VM compatibility.
Because I don't have the time to work on this mod, I used it as a fallback in the already existing system.
Library: https://bintray.com/karlatemp/unsafe-accessor/unsafe-accessor/ Github(outdated): https://github.com/Karlatemp/UnsafeAccessor How does it work: https://karlatemp.github.io/blog-me/reflect/0.index.html It uses a much more ingenious method to get Unsafe instance without trigger “WARNING: An illegal reflective access operation has occurred”. I think it can fix the compatibility issue with java 9+ perfectly. Just add jcenter to maven repo list and add content below to build.gradle:
implementation 'io.github.karlatemp:unsafe-accessor:1.2.0'
Useio.github.karlatemp.unsafeaccessor.Root.getUnsafe()
to get wrapped Unsafe and then callwrappedUnsafe.getUnsafe()
to get sun.misc.Unsafe. It also provides some useful methods likevoid io.github.karlatemp.unsafeaccessor.Root.setAccessible(AccessibleObject object, boolean isAccessible)
andMethodHandles.Lookup io.github.karlatemp.unsafeaccessor.Root.getTrusted()
.