liyafan82 commented on a change in pull request #7347:
URL: https://github.com/apache/arrow/pull/7347#discussion_r446639368



##########
File path: 
java/memory/src/main/java/org/apache/arrow/memory/util/MemoryUtil.java
##########
@@ -95,4 +143,26 @@ public static long getByteBufferAddress(ByteBuffer buf) {
 
   private MemoryUtil() {
   }
+
+  /**
+   * Create nio byte buffer.
+   */
+  public static ByteBuffer directBuffer(long address, int capacity) {
+    if (DIRECT_BUFFER_CONSTRUCTOR != null) {
+      if (capacity < 0) {
+        throw new IllegalArgumentException("Capacity is negative, has to be 
positive or 0");
+      }
+      try {
+        return (ByteBuffer) DIRECT_BUFFER_CONSTRUCTOR.newInstance(address, 
capacity);
+      } catch (Throwable cause) {
+        // Not expected to ever throw!
+        if (cause instanceof Error) {
+          throw (Error) cause;

Review comment:
       Is there a special reason for the cast here?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to