public static ByteBuffer newDirectByteBuffer ( long addr , int size , Object att ) { dbbCC . setAccessible ( true ) ; Object b = null ; try { b = dbbCC . newInstance ( new Long ( addr ) , new Integer ( size ) , att ) ; return ByteBuffer . class . cast ( b ) ; } catch ( Exception e ) { throw new IllegalStateException ( String . format ( "Failed to create DirectByteBuffer: %s" , e . getMessage ( ) ) ) ; } }
Create a new DirectByteBuffer from a given address and size . The returned DirectByteBuffer does not release the memory by itself .