Aligned long views over byte arrays and heap ByteBuffers

Paul Sandoz paul.sandoz at oracle.com
Fri Jan 15 16:41:43 UTC 2016


> On 15 Jan 2016, at 17:34, John Rose <john.r.rose at oracle.com> wrote:
> 
> On Jan 15, 2016, at 4:47 AM, Paul Sandoz <paul.sandoz at oracle.com <mailto:paul.sandoz at oracle.com>> 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;
>     }
> 

Thanks (and to Duncan too), i was not aware of that constructor.

Paul.


More information about the valhalla-dev mailing list