dongjoon-hyun 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_r291810225
 
 

 ##########
 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:
   Yes, it's because I only tested from Java 9 ~ 12. Since we don't know the 
future, the current intention is using the existing fallback logic to access 
`method` for Java 13+.

----------------------------------------------------------------
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]

Reply via email to