/**
   * This needs to be synchronized because of http://bugs.sun.com/view_bug.do?bug_id=6791815
   * http://mail.openjdk.java.net/pipermail/hotspot-runtime-dev/2009-January/000386.html
   */
  public static synchronized ByteBuffer newBuffer(final int size) {
    if (size % 512 != 0) {
      throw new RuntimeException("Buffer size needs to be aligned to 512");
    }

    return AsynchronousFileImpl.newNativeBuffer(size);
  }