Aligned long views over byte arrays and heap ByteBuffers

John Rose john.r.rose at
Fri Jan 15 16:34:33 UTC 2016

On Jan 15, 2016, at 4:47 AM, Paul Sandoz <paul.sandoz at> wrote:
> For the JDK implementation when a new DDB is allocated the address is guaranteed to be aligned (see Unsafe.allocateMemory), and the implementation takes advantage of that when viewing a DBB as a LongBuffer.

…Also, the JNI entry point NewDirectByteBuffer uses the address as-is, which is a feature not a bug.

    // Invoked only by JNI: NewDirectByteBuffer(void*, long)
    private Direct$Type$Buffer(long addr, int cap) {
        super(-1, 0, cap, cap);
        address = addr;
        cleaner = null;
        att = null;

More information about the valhalla-dev mailing list