--- old/src/java.base/share/classes/java/nio/Bits.java 2015-03-02 18:37:40.934869925 +0000 +++ new/src/java.base/share/classes/java/nio/Bits.java 2015-03-02 18:37:40.758875363 +0000 @@ -567,7 +567,8 @@ // -- Processor and memory-system properties -- - private static final ByteOrder byteOrder; + private static final ByteOrder byteOrder + = unsafe.getByteOrder() == Unsafe.LITTLE_ENDIAN ? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN; static ByteOrder byteOrder() { if (byteOrder == null) @@ -575,24 +576,6 @@ return byteOrder; } - static { - long a = unsafe.allocateMemory(8); - try { - unsafe.putLong(a, 0x0102030405060708L); - byte b = unsafe.getByte(a); - switch (b) { - case 0x01: byteOrder = ByteOrder.BIG_ENDIAN; break; - case 0x08: byteOrder = ByteOrder.LITTLE_ENDIAN; break; - default: - assert false; - byteOrder = null; - } - } finally { - unsafe.freeMemory(a); - } - } - - private static int pageSize = -1; static int pageSize() { @@ -613,8 +596,7 @@ return unaligned; String arch = AccessController.doPrivileged( new sun.security.action.GetPropertyAction("os.arch")); - unaligned = arch.equals("i386") || arch.equals("x86") - || arch.equals("amd64") || arch.equals("x86_64"); + unaligned = unsafe.unalignedAccess(); unalignedKnown = true; return unaligned; }