use of java.nio.DirectByteBuffer in project j2objc by google.
the class DirectFloatBufferTest method testJNIAccessByAddress.
// http://b/28964300
public void testJNIAccessByAddress() throws Exception {
DirectByteBuffer directByteBuffer = (DirectByteBuffer) ByteBuffer.allocateDirect(10);
directByteBuffer.put((byte) 'a');
FloatBuffer floatBuffer = directByteBuffer.asFloatBuffer();
long byteBufferBasePointer = NIOAccess.getBasePointer(directByteBuffer);
long floatBufferBasePointer = NIOAccess.getBasePointer(floatBuffer);
assertEquals(byteBufferBasePointer, floatBufferBasePointer);
// Check if the NIOAccess method adds up the current position value.
floatBuffer.put((float) 1);
assertEquals(floatBufferBasePointer + Float.BYTES, NIOAccess.getBasePointer(floatBuffer));
}
use of java.nio.DirectByteBuffer in project j2objc by google.
the class DirectLongBufferTest method testJNIAccessByAddress.
// http://b/28964300
public void testJNIAccessByAddress() throws Exception {
DirectByteBuffer directByteBuffer = (DirectByteBuffer) ByteBuffer.allocateDirect(10);
directByteBuffer.put((byte) 'a');
LongBuffer longBuffer = directByteBuffer.asLongBuffer();
long byteBufferBasePointer = NIOAccess.getBasePointer(directByteBuffer);
long longBufferBasePointer = NIOAccess.getBasePointer(longBuffer);
assertEquals(byteBufferBasePointer, longBufferBasePointer);
// Check if the NIOAccess method adds up the current position value.
longBuffer.put(1L);
assertEquals(longBufferBasePointer + Long.BYTES, NIOAccess.getBasePointer(longBuffer));
}
Aggregations