LuciferYang commented on a change in pull request #34368:
URL: https://github.com/apache/spark/pull/34368#discussion_r735276108
##########
File path: core/src/main/scala/org/apache/spark/util/ClosureCleaner.scala
##########
@@ -394,8 +395,17 @@ private[spark] object ClosureCleaner extends Logging {
parent = null, outerThis, capturingClass, accessedFields)
val outerField = func.getClass.getDeclaredField("arg$1")
+ // SPARK-37072: When Java 17 is used and `outerField` is read-only,
+ // the content of `outerField` cannot be set by reflect api directly.
+ // But we can remove the `final` modifier of `outerField` before set
value
+ // and reset the modifier after set value.
+ val modifiersField = getFinalModifiersFieldForJava17(outerField)
+ modifiersField
+ .foreach(m => m.setInt(outerField, outerField.getModifiers &
~Modifier.FINAL))
outerField.setAccessible(true)
outerField.set(func, clonedOuterThis)
+ modifiersField
+ .foreach(m => m.setInt(outerField, outerField.getModifiers |
Modifier.FINAL))
Review comment:
Thank you
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]