src/java.base/share/classes/java/nio/Bits.java
Print this page
*** 565,600 ****
}
// -- Processor and memory-system properties --
! private static final ByteOrder byteOrder;
static ByteOrder byteOrder() {
if (byteOrder == null)
throw new Error("Unknown byte order");
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() {
if (pageSize == -1)
pageSize = unsafe().pageSize();
--- 565,583 ----
}
// -- Processor and memory-system properties --
! private static final ByteOrder byteOrder
! = unsafe.isBigEndian() ? ByteOrder.BIG_ENDIAN : ByteOrder.LITTLE_ENDIAN;
static ByteOrder byteOrder() {
if (byteOrder == null)
throw new Error("Unknown byte order");
return byteOrder;
}
private static int pageSize = -1;
static int pageSize() {
if (pageSize == -1)
pageSize = unsafe().pageSize();
*** 609,622 ****
private static boolean unalignedKnown = false;
static boolean unaligned() {
if (unalignedKnown)
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");
unalignedKnown = true;
return unaligned;
}
--- 592,602 ----
private static boolean unalignedKnown = false;
static boolean unaligned() {
if (unalignedKnown)
return unaligned;
! unaligned = unsafe.unalignedAccess();
unalignedKnown = true;
return unaligned;
}