junit4 icon indicating copy to clipboard operation
junit4 copied to clipboard

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

Open cushon opened this issue 3 years ago • 0 comments

This code fails to compile on JDK 18 and newer:

https://github.com/junit-team/junit4/blob/cc7c500584fcb85eaf98c568b7441ceac6dd335c/src/main/java/org/junit/runner/Result.java#L190-L198

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

cushon avatar May 13 '22 22:05 cushon