Unsafe.{get,put}-X-Unaligned; Efficient array comparison intrinsics

Remi Forax forax at univ-mlv.fr
Sat Mar 7 17:57:31 UTC 2015


Hi Andrew,
I've just read carefully the JDK part and I'm mostly ok with it.

in Unsafe, all private methods should be static and
I think that isBigEndian() and unalignedAccess() native methods should 
be called once in a static block
and their results cached/stored as static final fields. In that case the 
public version of isBigEndian() and unalignedAccess()
should just return the value of the static final fields.
Also I'm wondering if this method are really unsafe, exporting the 
endianess or the support of unaligned access
doesn't seem unsafe too me; maybe there is a security issue ?; if not, 
the static final fields should be public and the public methods removed.

cheers,
Rémi

On 03/06/2015 07:50 PM, Andrew Haley wrote:
> I've tried to so everything I've been asked.  If this version passes
> muster with everyone I'll Javadoc all the public methods and fields
> and put it up for RFA next week.
>
> I guess it's going to need a lot of testing and security analysis.
>
> I added versions of all {put,get} methods with the boolean bigEndian
> argument.  This makes HeapByteBuffer much cleaner, and it does not
> need to know the machine endianness at all.  I hope that's OK.
>
> Andrew.
>
>
> http://cr.openjdk.java.net/~aph/unaligned.hotspot.4/
> http://cr.openjdk.java.net/~aph/unaligned.jdk.4/




More information about the core-libs-dev mailing list