This is an automated email from the ASF dual-hosted git repository. gurwls223 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 f94cc9f7e08 [SPARK-45295][CORE][SQL] Remove Utils.isMemberClass workaround for JDK 8 f94cc9f7e08 is described below commit f94cc9f7e0858697f04486bf52f34fbaa4b0106e Author: Hyukjin Kwon <gurwls...@apache.org> AuthorDate: Mon Sep 25 22:18:32 2023 +0900 [SPARK-45295][CORE][SQL] Remove Utils.isMemberClass workaround for JDK 8 ### What changes were proposed in this pull request? This PR removes the legacy workaround for JDK 8 added at SPARK-34607 ### Why are the changes needed? To remove legacy workaround. We dropped JDK 8 at SPARK-44112 ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? Existing unittest added in SPARK-34607 ### Was this patch authored or co-authored using generative AI tooling? No. Closes #43080 from HyukjinKwon/SPARK-45295. Authored-by: Hyukjin Kwon <gurwls...@apache.org> Signed-off-by: Hyukjin Kwon <gurwls...@apache.org> --- .../org/apache/spark/util/SparkClassUtils.scala | 28 ---------------------- .../spark/sql/catalyst/encoders/OuterScopes.scala | 2 +- .../sql/catalyst/expressions/objects/objects.scala | 2 +- 3 files changed, 2 insertions(+), 30 deletions(-) diff --git a/common/utils/src/main/scala/org/apache/spark/util/SparkClassUtils.scala b/common/utils/src/main/scala/org/apache/spark/util/SparkClassUtils.scala index 5984eaee42e..42d6d9fb421 100644 --- a/common/utils/src/main/scala/org/apache/spark/util/SparkClassUtils.scala +++ b/common/utils/src/main/scala/org/apache/spark/util/SparkClassUtils.scala @@ -50,34 +50,6 @@ private[spark] trait SparkClassUtils { def classIsLoadable(clazz: String): Boolean = { Try { classForName(clazz, initialize = false) }.isSuccess } - - /** - * Returns true if and only if the underlying class is a member class. - * - * Note: jdk8u throws a "Malformed class name" error if a given class is a deeply-nested - * inner class (See SPARK-34607 for details). This issue has already been fixed in jdk9+, so - * we can remove this helper method safely if we drop the support of jdk8u. - */ - def isMemberClass(cls: Class[_]): Boolean = { - try { - cls.isMemberClass - } catch { - case _: InternalError => - // We emulate jdk8u `Class.isMemberClass` below: - // public boolean isMemberClass() { - // return getSimpleBinaryName() != null && !isLocalOrAnonymousClass(); - // } - // `getSimpleBinaryName()` returns null if a given class is a top-level class, - // so we replace it with `cls.getEnclosingClass != null`. The second condition checks - // if a given class is not a local or an anonymous class, so we replace it with - // `cls.getEnclosingMethod == null` because `cls.getEnclosingMethod()` return a value - // only in either case (JVM Spec 4.8.6). - // - // Note: The newer jdk evaluates `!isLocalOrAnonymousClass()` first, - // we reorder the conditions to follow it. - cls.getEnclosingMethod == null && cls.getEnclosingClass != null - } - } } private[spark] object SparkClassUtils extends SparkClassUtils diff --git a/sql/api/src/main/scala/org/apache/spark/sql/catalyst/encoders/OuterScopes.scala b/sql/api/src/main/scala/org/apache/spark/sql/catalyst/encoders/OuterScopes.scala index b497cd3f386..85876889569 100644 --- a/sql/api/src/main/scala/org/apache/spark/sql/catalyst/encoders/OuterScopes.scala +++ b/sql/api/src/main/scala/org/apache/spark/sql/catalyst/encoders/OuterScopes.scala @@ -70,7 +70,7 @@ object OuterScopes { * useful for inner class defined in REPL. */ def getOuterScope(innerCls: Class[_]): () => AnyRef = { - if (!SparkClassUtils.isMemberClass(innerCls)) { + if (!innerCls.isMemberClass) { return null } val outerClass = innerCls.getDeclaringClass diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/objects/objects.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/objects/objects.scala index 32bcdaf8609..beb07259384 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/objects/objects.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/objects/objects.scala @@ -557,7 +557,7 @@ case class NewInstance( // Note that static inner classes (e.g., inner classes within Scala objects) don't need // outer pointer registration. val needOuterPointer = - outerPointer.isEmpty && Utils.isMemberClass(cls) && !Modifier.isStatic(cls.getModifiers) + outerPointer.isEmpty && cls.isMemberClass && !Modifier.isStatic(cls.getModifiers) childrenResolved && !needOuterPointer } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org For additional commands, e-mail: commits-h...@spark.apache.org