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

Andrew Haley aph at redhat.com
Mon Mar 9 09:11:19 UTC 2015


On 08/03/15 23:21, Remi Forax wrote:
> BE doesn't need to be an instance, method of Unsafe are instance methods 
> just to enforce security,
> you can not call them if you don"t have an instance of Unsafe (and 
> getUnsafe() does the security check).
> 
> BE is private so it doesn't have to be an instance field it can be 
> static field.
> 
> And I agree with you that the native isBigEndian() should be called once 
> in the lifetime of the VM.
> 
> so the idea is to write:
> 
> public boolean isBigEndian() {
>    return BE;
> }
> private static final boolean BE = isBigEndian0();
> 
> private static native boolean isBigEndian0();

I understand.  However, the callers of isBigEndian() do their own
caching, so it seems to me that this will be a case of double-caching.
It's not important from a performance point of view, but it is
additional complexity.

Andrew.



More information about the core-libs-dev mailing list