Class UnsafeAccess

java.lang.Object
org.cojen.tupl.io.UnsafeAccess

public class UnsafeAccess extends Object
Utility for accessing the unsupported Unsafe class.
  • Method Summary

    Modifier and Type
    Method
    Description
    static long
    alloc(int size)
    Allocate native memory.
    static long
    alloc(int size, boolean aligned)
    Allocate native memory.
    static long
    calloc(int size, boolean aligned)
    Allocate native memory, zero filled.
    static void
    copy(byte[] src, int srcOffset, long dstPtr, long len)
    Copy to native memory.
    static void
    copy(long srcPtr, byte[] dst, int dstOffset, long len)
    Copy from native memory.
    static void
    copy(long srcPtr, long dstPtr, long len)
    Copy native memory.
    static void
    fill(long ptr, long len, byte value)
    Fill a range of native memory.
    static void
    free(long ptr)
    Free allocated native memory.
    static sun.misc.Unsafe
     
    static sun.misc.Unsafe
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • tryObtain

      public static sun.misc.Unsafe tryObtain()
      Returns:
      null if not supported
    • obtain

      public static sun.misc.Unsafe obtain() throws UnsupportedOperationException
      Throws:
      UnsupportedOperationException - if not supported
    • alloc

      public static long alloc(int size)
      Allocate native memory.
    • alloc

      public static long alloc(int size, boolean aligned)
      Allocate native memory.
    • calloc

      public static long calloc(int size, boolean aligned)
      Allocate native memory, zero filled.
    • fill

      public static void fill(long ptr, long len, byte value)
      Fill a range of native memory.
    • copy

      public static void copy(long srcPtr, long dstPtr, long len)
      Copy native memory.
    • copy

      public static void copy(byte[] src, int srcOffset, long dstPtr, long len)
      Copy to native memory.
    • copy

      public static void copy(long srcPtr, byte[] dst, int dstOffset, long len)
      Copy from native memory.
    • free

      public static void free(long ptr)
      Free allocated native memory.