Fabric Zero (Discontinued)

Fabric Zero (Discontinued)

11.9k Downloads

Why not using UnsafeAccessor Library to get sun.misc.Unsafe instance with better compatibility and convenience.

lvyitian opened this issue · 1 comments

commented

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().

commented

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.