Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SPARK-37072][CORE] Pass all UTs in
repl
with Java 17
### What changes were proposed in this pull request? There are 9 UTs failed in `repl` run with Java 17, the all failed tests have similar error stack as follows: ``` java.lang.IllegalAccessException: Can not set final $iw field $Lambda$2879/0x000000080188b928.arg$1 to $iw at java.base/jdk.internal.reflect.UnsafeFieldAccessorImpl.throwFinalFieldIllegalAccessException(UnsafeFieldAccessorImpl.java:76) at java.base/jdk.internal.reflect.UnsafeFieldAccessorImpl.throwFinalFieldIllegalAccessException(UnsafeFieldAccessorImpl.java:80) at java.base/jdk.internal.reflect.UnsafeQualifiedObjectFieldAccessorImpl.set(UnsafeQualifiedObjectFieldAccessorImpl.java:79) at java.base/java.lang.reflect.Field.set(Field.java:799) at org.apache.spark.util.ClosureCleaner$.clean(ClosureCleaner.scala:398) at org.apache.spark.util.ClosureCleaner$.clean(ClosureCleaner.scala:162) at org.apache.spark.SparkContext.clean(SparkContext.scala:2490) at org.apache.spark.rdd.RDD.$anonfun$map$1(RDD.scala:414) at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:151) at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:112) at org.apache.spark.rdd.RDD.withScope(RDD.scala:406) at org.apache.spark.rdd.RDD.map(RDD.scala:413) ... 95 elided ``` We know from error stack that we can't reset a `read-only` field through the reflection api when use Java 17, the `read-only` field is defined as `private final field (trustedFinal=true)` . So this pr try to remove the `final` modifier before `outerField.set(func, clonedOuterThis)` in `ClosureCleaner#clean` method and reset the modifier value after `outerField.set(func, clonedOuterThis)` when use Java 17. At the same time, in order to use the API in `java.lang.reflect` mod, `--add-opens=java.base/java.lang.reflect=ALL-UNNAMED` is added to `pom.xml`, `SparkBuild.scala` and `JavaModuleOptions.java` ### Why are the changes needed? Pass UT with JDK 17 ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? - Pass the Jenkins or GitHub Action - Manual test use Java17 build + Java17 run (both openjdk version "17" 2021-09-14 LTS) Use Java 17 to run the following two commands ``` mvn clean install -pl repl -am -DskipTests mvn test -pl repl ``` **Before** ``` Run completed in 30 seconds, 826 milliseconds. Total number of tests run: 42 Suites: completed 6, aborted 0 Tests: succeeded 33, failed 9, canceled 0, ignored 0, pending 0 *** 9 TESTS FAILED *** ``` **After** ``` Run completed in 45 seconds, 86 milliseconds. Total number of tests run: 44 Suites: completed 7, aborted 0 Tests: succeeded 44, failed 0, canceled 0, ignored 0, pending 0 All tests passed. ``` - Manual test use Java8 build + Java17 run Use Java 8(openjdk version "1.8.0_292") to run the build command: ``` mvn clean install -pl repl -am -DskipTests ``` And Java 17(openjdk version "17" 2021-09-14 LTS) to run the test command: ``` mvn test -pl repl ``` **Before** ``` Run completed in 41 seconds, 855 milliseconds. Total number of tests run: 44 Suites: completed 7, aborted 0 Tests: succeeded 35, failed 9, canceled 0, ignored 0, pending 0 *** 9 TESTS FAILED *** ``` **After** ``` Run completed in 44 seconds, 596 milliseconds. Total number of tests run: 44 Suites: completed 7, aborted 0 Tests: succeeded 44, failed 0, canceled 0, ignored 0, pending 0 All tests passed. ``` Closes apache#34368 from LuciferYang/SPARK-37072. Authored-by: yangjie01 <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]>
- Loading branch information