This is an automated email from the ASF dual-hosted git repository.

dongjoon pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/master by this push:
     new a0dea7ca40bc [SPARK-45802][CORE] Remove no longer needed Java 
`majorVersion` checks in `Platform`
a0dea7ca40bc is described below

commit a0dea7ca40bcd0340b72dff356b3e27ecefc45b7
Author: yangjie01 <yangji...@baidu.com>
AuthorDate: Tue Nov 7 09:44:12 2023 -0800

    [SPARK-45802][CORE] Remove no longer needed Java `majorVersion` checks in 
`Platform`
    
    ### What changes were proposed in this pull request?
    This  PR removes the version checks for Java 9 and 11 from `Platform` 
because Spark 4.0 minimum supports Java 17.
    
    ### Why are the changes needed?
    Remove no longer needed Java `majorVersion` checks.
    
    ### Does this PR introduce _any_ user-facing change?
    No
    
    ### How was this patch tested?
    Pass GitHub Actions
    
    ### Was this patch authored or co-authored using generative AI tooling?
    No
    
    Closes #43672 from LuciferYang/SPARK-45802.
    
    Lead-authored-by: yangjie01 <yangji...@baidu.com>
    Co-authored-by: YangJie <yangji...@baidu.com>
    Signed-off-by: Dongjoon Hyun <dh...@apple.com>
---
 .../src/main/java/org/apache/spark/unsafe/Platform.java | 17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)

diff --git a/common/unsafe/src/main/java/org/apache/spark/unsafe/Platform.java 
b/common/unsafe/src/main/java/org/apache/spark/unsafe/Platform.java
index dfa5734ccbce..9d97d04a5813 100644
--- a/common/unsafe/src/main/java/org/apache/spark/unsafe/Platform.java
+++ b/common/unsafe/src/main/java/org/apache/spark/unsafe/Platform.java
@@ -59,13 +59,6 @@ public final class Platform {
     // reflection to invoke it, which is not necessarily possible by default 
in Java 9+.
     // Code below can test for null to see whether to use it.
 
-    // The implementation of Cleaner changed from JDK 8 to 9
-    String cleanerClassName;
-    if (majorVersion < 9) {
-      cleanerClassName = "sun.misc.Cleaner";
-    } else {
-      cleanerClassName = "jdk.internal.ref.Cleaner";
-    }
     try {
       Class<?> cls = Class.forName("java.nio.DirectByteBuffer");
       Constructor<?> constructor = (majorVersion < 21) ?
@@ -84,7 +77,7 @@ public final class Platform {
 
       // no point continuing if the above failed:
       if (DBB_CONSTRUCTOR != null && DBB_CLEANER_FIELD != null) {
-        Class<?> cleanerClass = Class.forName(cleanerClassName);
+        Class<?> cleanerClass = Class.forName("jdk.internal.ref.Cleaner");
         Method createMethod = cleanerClass.getMethod("create", Object.class, 
Runnable.class);
         // Accessing jdk.internal.ref.Cleaner should actually fail by default 
in JDK 9+,
         // unfortunately, unless the user has allowed access with something 
like
@@ -314,7 +307,7 @@ public final class Platform {
     }
   }
 
-  // This requires `majorVersion` and `_UNSAFE`.
+  // This requires `_UNSAFE`.
   static {
     boolean _unaligned;
     String arch = System.getProperty("os.arch", "");
@@ -326,10 +319,8 @@ public final class Platform {
       try {
         Class<?> bitsClass =
           Class.forName("java.nio.Bits", false, 
ClassLoader.getSystemClassLoader());
-        if (_UNSAFE != null && majorVersion >= 9) {
-          // Java 9/10 and 11/12 have different field names.
-          Field unalignedField =
-            bitsClass.getDeclaredField(majorVersion >= 11 ? "UNALIGNED" : 
"unaligned");
+        if (_UNSAFE != null) {
+          Field unalignedField = bitsClass.getDeclaredField("UNALIGNED");
           _unaligned = _UNSAFE.getBoolean(
             _UNSAFE.staticFieldBase(unalignedField), 
_UNSAFE.staticFieldOffset(unalignedField));
         } else {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org
For additional commands, e-mail: commits-h...@spark.apache.org

Reply via email to