Skip to content

Throw correct exception when initialization already failed - #14352

Merged
pshipton merged 1 commit into
eclipse-openj9:masterfrom
EricYangIBM:exceptionInInitializer
Jan 27, 2022
Merged

Throw correct exception when initialization already failed#14352
pshipton merged 1 commit into
eclipse-openj9:masterfrom
EricYangIBM:exceptionInInitializer

Conversation

@EricYangIBM

Copy link
Copy Markdown
Contributor

Throw correct exception when initialization already failed

When initialization has already failed for a class before, throw
NoClassDefFoundError with ExceptionInInitializerError as its cause
instead of the Throwable that caused the first initialization failure.

Supersedes #14291 (renamed branch)
Fixes: #14080
Signed-off-by: Eric Yang eric.yang@ibm.com

@EricYangIBM EricYangIBM changed the title Exception in initializer Throw correct exception when initialization already failed Jan 24, 2022
@tajila
tajila requested a review from babsingh January 25, 2022 15:15
if (err instanceof Error) {
throw (Error)err;
}
throw new ExceptionInInitializerError(err);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@babsingh Perhaps this is still necessary if recordInitializationFailure skips the if (initialized) block

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, it's possible. let's keep it.

@babsingh babsingh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feedback and comments in #14291 still apply to this PR. The old PR (#14291) was created using a branch name which included *Error. This caused test failures. So, a new PR with a different branch name was created.

These changes LGTM since the JVM spec (Section 5.5 Initialization) is correctly satisfied:

If the class of E is not Error or one of its subclasses, then create a new instance of the class ExceptionInInitializerError with E as the argument, and use this object in place of E in the following step.

Approving. @EricYangIBM These changes only modify the error handling. So, the segfaults in your personal builds are not possibly due to these changes. You can squash the three commits.

@tajila Request for review, PR builds and merge.

@EricYangIBM

EricYangIBM commented Jan 26, 2022

Copy link
Copy Markdown
Contributor Author

Ran sanity.openjdk on temporary branch (that this branch now matches) and the previously numerous segfaults are now (mostly) gone: https://hyc-runtimes-jenkins.swg-devops.com/job/Test_openjdk18_j9_sanity.openjdk_x86-64_linux_Personal/19/
The four failures are also seen with builds on master

@pshipton

Copy link
Copy Markdown
Member

I believe the sanity.openjdk failures are related to AOT code and intermittent. Sometimes they happen and sometimes not, and they can affect a different number of tests in a run. Agree they aren't related to this change.

@pshipton pshipton added the jdk18 label Jan 26, 2022
@pshipton

Copy link
Copy Markdown
Member

jenkins compile alinux64 jdk18

@pshipton

Copy link
Copy Markdown
Member

Actually the commits are not squashed. Once that is done I would merge.

@pshipton

Copy link
Copy Markdown
Member

We'd better run sanity and extended just in case there is some functionality test that expects the old behaviour.

When initialization has already failed for a class before, throw
`NoClassDefFoundError` with `ExceptionInInitializerError` as its cause
instead of the `Throwable` that caused the first initialization failure.

Fixes: eclipse-openj9#14080
Signed-off-by: Eric Yang <eric.yang@ibm.com>
@EricYangIBM
EricYangIBM force-pushed the exceptionInInitializer branch from 055b4ef to 6cd666f Compare January 27, 2022 14:01
@EricYangIBM

Copy link
Copy Markdown
Contributor Author

Commits are squashed. I have only run and verified sanity.functional and sanity.openjdk for xlinux jdk11, 17, and 18. Perhaps I could also run some internal builds.

@EricYangIBM

Copy link
Copy Markdown
Contributor Author

zOS and Windows internal builds passed: https://hyc-runtimes-jenkins.swg-devops.com/job/jvm.29.personal/30428/

@pshipton

Copy link
Copy Markdown
Member

jenkins test sanity,extended alinux64 jdk18

@pshipton
pshipton merged commit 174e82d into eclipse-openj9:master Jan 27, 2022
@pshipton

Copy link
Copy Markdown
Member

@EricYangIBM pls create a PR to un-exclude the test.

EricYangIBM added a commit to EricYangIBM/aqa-tests that referenced this pull request Jan 27, 2022
Original issue: eclipse-openj9/openj9#14080
Fixed by: eclipse-openj9/openj9#14352
Signed-off-by: Eric Yang <eric.yang@ibm.com>
@EricYangIBM
EricYangIBM deleted the exceptionInInitializer branch January 27, 2022 18:21
@EricYangIBM

Copy link
Copy Markdown
Contributor Author

PR: adoptium/aqa-tests#3295

smlambert pushed a commit to adoptium/aqa-tests that referenced this pull request Jan 28, 2022
Original issue: eclipse-openj9/openj9#14080
Fixed by: eclipse-openj9/openj9#14352
Signed-off-by: Eric Yang <eric.yang@ibm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[JDK18] j.l.RuntimeException: InvocationTargetException was thrown not due to error while initialization!

3 participants