public long getByteBufferAddress ( ByteBuffer byteBuffer ) { /* * This only works for DIRECT byte buffers. Direct ByteBuffers have a field * called "address" which * holds the physical address of the start of the buffer contents in native * memory. * This method obtains the value of the address field through reflection. */ if ( ! byteBuffer . isDirect ( ) ) { throw new IllegalArgumentException ( "The specified byte buffer is not direct" ) ; } try { return svAddrField . getLong ( byteBuffer ) ; } catch ( IllegalAccessException exception ) { throw new RuntimeException ( exception . getMessage ( ) ) ; } }
Get the native address for the specified DirectByteBuffer