srowen commented on a change in pull request #24825: [SPARK-27981][CORE] Remove
`Illegal reflective access` warning for `java.nio.Bits.unaligned()` in JDK9+
URL: https://github.com/apache/spark/pull/24825#discussion_r291815204
##########
File path: common/unsafe/src/main/java/org/apache/spark/unsafe/Platform.java
##########
@@ -319,4 +301,36 @@ public static void throwException(Throwable t) {
DOUBLE_ARRAY_OFFSET = 0;
}
}
+
+ // This requires `majorVersion` and `_UNSAFE`.
+ static {
+ boolean _unaligned;
+ String arch = System.getProperty("os.arch", "");
+ if (arch.equals("ppc64le") || arch.equals("ppc64")) {
+ // Since java.nio.Bits.unaligned() doesn't return true on ppc (See
JDK-8165231), but
+ // ppc64 and ppc64le support it
+ _unaligned = true;
+ } else {
+ try {
+ Class<?> bitsClass =
+ Class.forName("java.nio.Bits", false,
ClassLoader.getSystemClassLoader());
+ if (_UNSAFE != null && 9 <= majorVersion && majorVersion <= 12) {
Review comment:
I'd remove it. Otherwise don't you fall back to the previous behavior in
Java 13? more likely to work like Java 12 than 8.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]