-
Notifications
You must be signed in to change notification settings - Fork 28.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SPARK-34607][SQL][3.1] Add Utils.isMemberClass
to fix a malformed class name error on jdk8u
#31745
Conversation
Kubernetes integration test starting |
Kubernetes integration test status success |
Hi, @maropu .
|
@dongjoon-hyun Ah, ok. Looks like the added test in this PR hit the issue handled in #31709. So, I think we need to backport it before merging this PR. |
Test build #135781 has finished for PR 31745 at commit
|
Yes, I verified that this passes with that patch, @maropu . |
We need both patches together because that one also causes UT failure in branch-3.1 and is reverted. Let me handle it manually. (cc @HyukjinKwon and @rednaxelafx ) |
Hmm. I cherry-pick the original patch to |
Never mind, @maropu . I merged this manually by resolve conflicts. |
For the record,
As reported, the test suite succeeds individually, but it seems to fail in a bulk-run.
|
What changes were proposed in this pull request?
This PR intends to fix a bug of
objects.NewInstance
if a user runs Spark on jdk8u and a givencls
inNewInstance
is a deeply-nested inner class, e.g.,.The root cause that Kris (@rednaxelafx) investigated is as follows (Kudos to Kris);
The reason why the test case above is so convoluted is in the way Scala generates the class name for nested classes. In general, Scala generates a class name for a nested class by inserting the dollar-sign (
$
) in between each level of class nesting. The problem is that this format can concatenate into a very long string that goes beyond certain limits, so Scala will change the class name format beyond certain length threshold.For the example above, we can see that the first two levels of class nesting have class names that look like this:
If we leave out the fact that Scala uses a dollar-sign (
$
) suffix for the class name of the companion object,OuterLevelWithVeryVeryVeryLongClassName1
's full name is a prefix (substring) ofOuterLevelWithVeryVeryVeryLongClassName2
.But if we keep going deeper into the levels of nesting, you'll find names that look like:
with a hash code in the middle and various levels of nesting omitted.
The
java.lang.Class.isMemberClass
method is implemented in JDK8u as:http://hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/tip/src/share/classes/java/lang/Class.java#l1425
and the problematic code is
getName().substring(enclosingClass.getName().length())
-- if a class's enclosing class's full name is longer than the nested class's full name, this logic would end up going out of bounds.The bug has been fixed in JDK9 by https://bugs.java.com/bugdatabase/view_bug.do?bug_id=8057919 , but still exists in the latest JDK8u release. So from the Spark side we'd need to do something to avoid hitting this problem.
This is the backport of #31733.
Why are the changes needed?
Bugfix on jdk8u.
Does this PR introduce any user-facing change?
No.
How was this patch tested?
Added tests.