How do I get the instance of the unsafe class?
I always get the security exception. I listed the code of the OpenJDK 6 implementation. I would like to mess around with
From baeldung.com, we can obtain the instance using reflection:
Field f =Unsafe.class.getDeclaredField("theUnsafe");
f.setAccessible(true);
unsafe = (Unsafe) f.get(null);
Edit
The following is quoted from the description of the project where this code belongs to.
"The implementation of all these examples and code snippets can be found over on GitHub – this is a Maven project, so it should be easy to import and run as it is."