Skip to content
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

Compilation error in org.junit.runner.Result - ObjectInputStream.GetField.get(name, object) throws ClassNotFoundException #1739

Closed
cushon opened this issue May 13, 2022 · 0 comments · Fixed by #1740
Assignees

Comments

@cushon
Copy link

cushon commented May 13, 2022

This code fails to compile on JDK 18 and newer:

@SuppressWarnings("unchecked")
private SerializedForm(ObjectInputStream.GetField fields) throws IOException {
fCount = (AtomicInteger) fields.get("fCount", null);
fIgnoreCount = (AtomicInteger) fields.get("fIgnoreCount", null);
assumptionFailureCount = (AtomicInteger) fields.get("assumptionFailureCount", null);
fFailures = (List<Failure>) fields.get("fFailures", null);
fRunTime = fields.get("fRunTime", 0L);
fStartTime = fields.get("fStartTime", 0L);
}

src/main/java/org/junit/runner/Result.java:192: error: unreported exception ClassNotFoundException; must be caught or declared to be thrown
            fCount = (AtomicInteger) fields.get("fCount", null);
                                               ^
src/main/java/org/junit/runner/Result.java:193: error: unreported exception ClassNotFoundException; must be caught or declared to be thrown
            fIgnoreCount = (AtomicInteger) fields.get("fIgnoreCount", null);
                                                     ^
src/main/java/org/junit/runner/Result.java:194: error: unreported exception ClassNotFoundException; must be caught or declared to be thrown
            assumptionFailureCount = (AtomicInteger) fields.get("assumptionFailureCount", null);
                                                               ^
src/main/java/org/junit/runner/Result.java:195: error: unreported exception ClassNotFoundException; must be caught or declared to be thrown
            fFailures = (List<Failure>) fields.get("fFailures", null);
                                                  ^

This is the corresponding JDK change: https://bugs.openjdk.java.net/browse/JDK-8276742

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants