package org.jctools.util;

import java.lang.reflect.Field;

import sun.misc.Unsafe;

public class UnsafeAccess {
    public static final Unsafe UNSAFE;
    static {
        try {
            // This is a bit of voodoo to force the unsafe object into
            // visibility and acquire it.
            // This is not playing nice, but as an established back door it is
            // not likely to be
            // taken away.
            final Field field = Unsafe.class.getDeclaredField("theUnsafe");
            field.setAccessible(true);
            UNSAFE = (Unsafe) field.get(null);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

}

@@ -56,33 +56,706 @@
 ld;%0A
-%0Aimport sun.misc.Unsafe;%0A
+import java.util.concurrent.atomic.AtomicReferenceArray;%0Aimport java.util.concurrent.atomic.AtomicReferenceFieldUpdater;%0A%0Aimport sun.misc.Unsafe;%0A%0A/**%0A * Why should we resort to using Unsafe?%3Cbr%3E%0A * %3Col%3E%0A * %3Cli%3ETo construct class fields which allow volatile/ordered/plain access: This requirement is covered by%0A * %7B@link AtomicReferenceFieldUpdater%7D and similar but their performance is arguably worse than the DIY approach%0A * (depending on JVM version) while Unsafe intrinsification is a far lesser challenge for JIT compilers.%0A * %3Cli%3ETo construct flavors of %7B@link AtomicReferenceArray%7D.%0A * %3Cli%3EOther use cases exist but are not present in this library yet.%0A * %3Col%3E%0A * %0A * @author nitsanw%0A * %0A */
 %0Apub
@@ -850,33 +850,48 @@
  %7B%0A            /
-/
+*%0A             *
  This is a bit o
@@ -930,31 +930,16 @@
 ect into
-%0A            //
  visibil
@@ -957,31 +957,16 @@
 uire it.
-%0A            //
  This is
@@ -977,16 +977,31 @@
  playing
+%0A             *
  nice, b
@@ -1036,31 +1036,16 @@
 or it is
-%0A            //
  not lik
@@ -1057,35 +1057,36 @@
 o be
-%0A            // taken away.
+ taken away.%0A             */
 %0A   

Add comment justifying the use of UNSAFE.