View Javadoc
1   package com.github.davidmoten.rx2.internal.flowable.buffertofile;
2   
3   import java.lang.reflect.Field;
4   
5   import sun.misc.Unsafe;
6   
7   @SuppressWarnings("restriction")
8   public final class UnsafeAccess {
9   
10      private UnsafeAccess() {
11          // prevent instantiation
12      }
13  
14      private static Unsafe unsafe;
15  
16      static {
17          try {
18              Field singleoneInstanceField = Unsafe.class.getDeclaredField("theUnsafe");
19              singleoneInstanceField.setAccessible(true);
20              unsafe = (Unsafe) singleoneInstanceField.get(null);
21          } catch (Exception e) {
22              throw new RuntimeException(e);
23          }
24      }
25  
26      public static Unsafe unsafe() {
27          return unsafe;
28      }
29  
30  }