Skip to content

Commit b03352b

Browse files
sarutakLuciferYang
authored andcommitted
[SPARK-54394][CORE] Move isJavaVersionAtMost17 and isJavaVersionAtLeast21 from core to common/utils
### What changes were proposed in this pull request? This PR proposes to move `isJavaVersionAtMost17` and `isJavaVersionAtLeast21` from `Utils.scala` in `core` to `SparkSystemUtils.scala` in `common/utils` ### Why are the changes needed? To allow components which don't depend on `core` (like components under `common/utils`) use these methods. These utility methods can be commonly used like `javeVersion` in `SparkSystemUtils.scala`. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? GA. ### Was this patch authored or co-authored using generative AI tooling? No. Closes #53108 from sarutak/move-java-version. Authored-by: Kousuke Saruta <sarutak@amazon.co.jp> Signed-off-by: yangjie01 <yangjie01@baidu.com>
1 parent fd683ce commit b03352b

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

common/utils/src/main/scala/org/apache/spark/util/SparkSystemUtils.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,16 @@ private[spark] trait SparkSystemUtils {
3939
*/
4040
val javaVersion = JavaUtils.javaVersion
4141

42+
/**
43+
* Whether the underlying Java version is at most 17.
44+
*/
45+
val isJavaVersionAtMost17 = Runtime.version().feature() <= 17
46+
47+
/**
48+
* Whether the underlying Java version is at least 21.
49+
*/
50+
val isJavaVersionAtLeast21 = Runtime.version().feature() >= 21
51+
4252
/**
4353
* Whether the underlying operating system is Windows.
4454
*/
@@ -63,6 +73,7 @@ private[spark] trait SparkSystemUtils {
6373
* Whether the underlying operating system is UNIX.
6474
*/
6575
val isUnix = JavaUtils.isUnix
76+
6677
}
6778

6879
object SparkSystemUtils extends SparkSystemUtils

core/src/main/scala/org/apache/spark/util/Utils.scala

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1855,16 +1855,6 @@ private[spark] object Utils
18551855
getHadoopFileSystem(new URI(path), conf)
18561856
}
18571857

1858-
/**
1859-
* Whether the underlying Java version is at most 17.
1860-
*/
1861-
val isJavaVersionAtMost17 = Runtime.version().feature() <= 17
1862-
1863-
/**
1864-
* Whether the underlying Java version is at least 21.
1865-
*/
1866-
val isJavaVersionAtLeast21 = Runtime.version().feature() >= 21
1867-
18681858
/**
18691859
* Whether the underlying JVM prefer IPv6 addresses.
18701860
*/

0 commit comments

Comments
 (0)