On 03/09/2015 12:11 AM, David Holmes wrote:
On 7/03/2015 4:50 AM, 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/

I think it is cleaner and more efficient if Unsafe maintains BE as an instance variable (initialized at construction) and that isBigEndian() simply returns that. The native check should only need to be called once in the lifetime of the VM.

David


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();

cheers,
Rémi

Reply via email to