Here you can find the source of getAddressFromDirectByteBuffer(ByteBuffer buffer)
Parameter | Description |
---|---|
buffer | a parameter |
public static long getAddressFromDirectByteBuffer(ByteBuffer buffer)
//package com.java2s; //License from project: Apache License import java.lang.reflect.Field; import java.nio.Buffer; import java.nio.ByteBuffer; public class Main { /**/*w w w . ja v a 2 s . c o m*/ * Gets the address value for the memory that backs a direct byte buffer. * * @param buffer * @return The system address for the buffers */ public static long getAddressFromDirectByteBuffer(ByteBuffer buffer) { try { Field addressField = Buffer.class.getDeclaredField("address"); addressField.setAccessible(true); return addressField.getLong(buffer); } catch (Exception e) { throw new RuntimeException("Unable to address field from ByteBuffer", e); } } }