[SPARK-46939][CORE] Remove isClosureCandidate check from getSerializationProxy function in IndylambdaScalaClosures#44977
Conversation
| case c if !c.isSynthetic || !maybeClosure.isInstanceOf[Serializable] => None | ||
|
|
||
| case c if isClosureCandidate(c) => | ||
| case _ => |
There was a problem hiding this comment.
cc @rednaxelafx May I ask if this modification attempt is correct? Thanks
isClosureCandidate check from getSerializationProxy function in IndylambdaScalaClosures
|
I'm neutral on lifting the My original intent with the The special thing about language-level lambdas is that you can have higher confidence in that the class is generated by the compiler (or at least the recipe of the class comes from the compiler), so they'll follow certain patterns and won't have surprises with fields that are hand-added. It certainly is possible to abuse the imperfect checks/filters I had put in place, to trick the cleaner to trust a non-compiler-generated class as being a Scala lambda... there's quite some room for improvement here. @vsevolodstep-db Seva had been working on ClosureCleaner improvements like this one (#42995) which found quite some cases that I didn't handle right... |
|
@rednaxelafx I haven't thought of many of the issues you mentioned, thank you very much for your explanation. At the same time, I think it's better to keep the current state, so let me close this pull request first. Thanks ~ |
What changes were proposed in this pull request?
This PR simplifies the
getSerializationProxyfunction in theIndylambdaScalaClosures. The main change is to remove theisClosureCandidatecheck when determining if a class is a closure because Apache Spark 4.0 no longer support Scala 2.11.Why are the changes needed?
The reason for removing the
isClosureCandidatecheck is that in Scala 2.12 and later versions, closures are implemented as synthetic classes generated by the Java LambdaMetafactory. These synthetic classes do not need to implement thescala.Functioninterface, which is what theisClosureCandidatecheck was originally checking for. Therefore, theisClosureCandidatecheck is not necessary for identifying closures in Scala 2.12 and later versions.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