HBASE-17869 UnsafeAvailChecker wrongly returns false on ppc
This commit is contained in:
parent
9109803891
commit
af604f0c0c
|
@ -51,15 +51,21 @@ public class UnsafeAvailChecker {
|
||||||
});
|
});
|
||||||
// When Unsafe itself is not available/accessible consider unaligned as false.
|
// When Unsafe itself is not available/accessible consider unaligned as false.
|
||||||
if (avail) {
|
if (avail) {
|
||||||
try {
|
String arch = System.getProperty("os.arch");
|
||||||
// Using java.nio.Bits#unaligned() to check for unaligned-access capability
|
if ("ppc64".equals(arch) || "ppc64le".equals(arch)) {
|
||||||
Class<?> clazz = Class.forName("java.nio.Bits");
|
// java.nio.Bits.unaligned() wrongly returns false on ppc (JDK-8165231),
|
||||||
Method m = clazz.getDeclaredMethod("unaligned");
|
unaligned = true;
|
||||||
m.setAccessible(true);
|
} else {
|
||||||
unaligned = (Boolean) m.invoke(null);
|
try {
|
||||||
} catch (Exception e) {
|
// Using java.nio.Bits#unaligned() to check for unaligned-access capability
|
||||||
LOG.warn("java.nio.Bits#unaligned() check failed."
|
Class<?> clazz = Class.forName("java.nio.Bits");
|
||||||
+ "Unsafe based read/write of primitive types won't be used", e);
|
Method m = clazz.getDeclaredMethod("unaligned");
|
||||||
|
m.setAccessible(true);
|
||||||
|
unaligned = (Boolean) m.invoke(null);
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOG.warn("java.nio.Bits#unaligned() check failed."
|
||||||
|
+ "Unsafe based read/write of primitive types won't be used", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue