// Path: src/main/java/org/lmdbjava/Env.java
// public static final boolean SHOULD_CHECK = !getBoolean(DISABLE_CHECKS_PROP);
// 
// Path: src/main/java/org/lmdbjava/UnsafeAccess.java
// static final Unsafe UNSAFE;


import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.util.ArrayDeque;
import jnr.ffi.Pointer;
import static java.lang.Long.reverseBytes;
import static java.lang.ThreadLocal.withInitial;
import static java.nio.ByteBuffer.allocateDirect;
import static java.nio.ByteOrder.BIG_ENDIAN;
import static java.nio.ByteOrder.LITTLE_ENDIAN;
import static java.util.Objects.requireNonNull;
import static org.lmdbjava.Env.SHOULD_CHECK;
import static org.lmdbjava.UnsafeAccess.UNSAFE;
import java.lang.reflect.Field;
    @Override
    protected ByteBuffer out(final ByteBuffer buffer, final Pointer ptr,
                             final long ptrAddr) {
      final long addr = ptr.getAddress(STRUCT_FIELD_OFFSET_DATA);
      final long size = ptr.getLong(STRUCT_FIELD_OFFSET_SIZE);
      try {
        ADDRESS_FIELD.set(buffer, addr);
        CAPACITY_FIELD.set(buffer, (int) size);
      } catch (final IllegalArgumentException | IllegalAccessException e) {
        throw new LmdbException("Cannot modify buffer", e);
      }
      buffer.clear();
      return buffer;
    }

  }

  /**
   * A proxy that uses Java's "unsafe" class to directly manipulate byte buffer
   * fields and JNR-FFF allocated memory pointers.
   */
  private static final class UnsafeProxy extends AbstractByteBufferProxy {

    private static final long ADDRESS_OFFSET;
    private static final long CAPACITY_OFFSET;

    static {
      try {
        final Field address = findField(Buffer.class, FIELD_NAME_ADDRESS);
        final Field capacity = findField(Buffer.class, FIELD_NAME_CAPACITY);
// Path: src/main/java/org/lmdbjava/Env.java
// public static final boolean SHOULD_CHECK = !getBoolean(DISABLE_CHECKS_PROP);
// 
// Path: src/main/java/org/lmdbjava/UnsafeAccess.java
// static final Unsafe UNSAFE;


// Path: src/main/java/org/lmdbjava/ByteBufferProxy.java
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.util.ArrayDeque;
import jnr.ffi.Pointer;
import static java.lang.Long.reverseBytes;
import static java.lang.ThreadLocal.withInitial;
import static java.nio.ByteBuffer.allocateDirect;
import static java.nio.ByteOrder.BIG_ENDIAN;
import static java.nio.ByteOrder.LITTLE_ENDIAN;
import static java.util.Objects.requireNonNull;
import static org.lmdbjava.Env.SHOULD_CHECK;
import static org.lmdbjava.UnsafeAccess.UNSAFE;
import java.lang.reflect.Field;

    @Override
    protected ByteBuffer out(final ByteBuffer buffer, final Pointer ptr,
                             final long ptrAddr) {
      final long addr = ptr.getAddress(STRUCT_FIELD_OFFSET_DATA);
      final long size = ptr.getLong(STRUCT_FIELD_OFFSET_SIZE);
      try {
        ADDRESS_FIELD.set(buffer, addr);
        CAPACITY_FIELD.set(buffer, (int) size);
      } catch (final IllegalArgumentException | IllegalAccessException e) {
        throw new LmdbException("Cannot modify buffer", e);
      }
      buffer.clear();
      return buffer;
    }

  }

  /**
   * A proxy that uses Java's "unsafe" class to directly manipulate byte buffer
   * fields and JNR-FFF allocated memory pointers.
   */
  private static final class UnsafeProxy extends AbstractByteBufferProxy {

    private static final long ADDRESS_OFFSET;
    private static final long CAPACITY_OFFSET;

    static {
      try {
        final Field address = findField(Buffer.class, FIELD_NAME_ADDRESS);
        final Field capacity = findField(Buffer.class, FIELD_NAME_CAPACITY);
        ADDRESS_OFFSET = UNSAFE.objectFieldOffset(address);