junit-team / junit4

A programmer-oriented testing framework for Java.
https://junit.org/junit4
Eclipse Public License 1.0
8.51k stars 3.24k forks source link

junit-4.13.2 compilation error with java 21 #1766

Open vaukai opened 8 months ago

vaukai commented 8 months ago

From https://bugs.gentoo.org/916398

 * Package:    dev-java/junit-4.13.2:4
 * Repository: gentoo
 * Maintainer: java@gentoo.org
 * USE:        abi_x86_64 amd64 elibc_glibc kernel_linux
 * FEATURES:   network-sandbox preserve-libs sandbox userpriv usersandbox
debug:   eclass exists: /var/db/repos/vaukai/eclass/java-pkg-2.eclass
debug: inherit: java-pkg-2 -> /var/db/repos/vaukai/eclass/java-pkg-2.eclass
debug: *** Multiple Inheritance (Level: 2)
debug:   eclass exists: /var/db/repos/vaukai/eclass/java-utils-2.eclass
debug: inherit: java-utils-2 -> /var/db/repos/vaukai/eclass/java-utils-2.eclass
debug: EXPORT_FUNCTIONS: pkg_setup -> java-pkg-2_pkg_setup
debug: EXPORT_FUNCTIONS: src_prepare -> java-pkg-2_src_prepare
debug: EXPORT_FUNCTIONS: src_compile -> java-pkg-2_src_compile
debug: EXPORT_FUNCTIONS: pkg_preinst -> java-pkg-2_pkg_preinst
debug:   eclass exists: /var/db/repos/vaukai/eclass/java-pkg-simple.eclass
debug: inherit: java-pkg-simple -> /var/db/repos/vaukai/eclass/java-pkg-simple.eclass
debug: *** Multiple Inheritance (Level: 2)
debug:   eclass exists: /var/db/repos/vaukai/eclass/java-utils-2.eclass
debug: inherit: java-utils-2 -> /var/db/repos/vaukai/eclass/java-utils-2.eclass
debug: EXPORT_FUNCTIONS: src_compile -> java-pkg-simple_src_compile
debug: EXPORT_FUNCTIONS: src_install -> java-pkg-simple_src_install
debug: EXPORT_FUNCTIONS: src_test -> java-pkg-simple_src_test
 * Package:    dev-java/junit-4.13.2:4
 * Repository: gentoo
 * Maintainer: java@gentoo.org
 * USE:        abi_x86_64 amd64 elibc_glibc kernel_linux
 * FEATURES:   network-sandbox preserve-libs sandbox userpriv usersandbox
debug:   eclass exists: /var/db/repos/vaukai/eclass/java-pkg-2.eclass
debug: inherit: java-pkg-2 -> /var/db/repos/vaukai/eclass/java-pkg-2.eclass
debug: *** Multiple Inheritance (Level: 2)
debug:   eclass exists: /var/db/repos/vaukai/eclass/java-utils-2.eclass
debug: inherit: java-utils-2 -> /var/db/repos/vaukai/eclass/java-utils-2.eclass
debug: EXPORT_FUNCTIONS: pkg_setup -> java-pkg-2_pkg_setup
debug: EXPORT_FUNCTIONS: src_prepare -> java-pkg-2_src_prepare
debug: EXPORT_FUNCTIONS: src_compile -> java-pkg-2_src_compile
debug: EXPORT_FUNCTIONS: pkg_preinst -> java-pkg-2_pkg_preinst
debug:   eclass exists: /var/db/repos/vaukai/eclass/java-pkg-simple.eclass
debug: inherit: java-pkg-simple -> /var/db/repos/vaukai/eclass/java-pkg-simple.eclass
debug: *** Multiple Inheritance (Level: 2)
debug:   eclass exists: /var/db/repos/vaukai/eclass/java-utils-2.eclass
debug: inherit: java-utils-2 -> /var/db/repos/vaukai/eclass/java-utils-2.eclass
debug: EXPORT_FUNCTIONS: src_compile -> java-pkg-simple_src_compile
debug: EXPORT_FUNCTIONS: src_install -> java-pkg-simple_src_install
debug: EXPORT_FUNCTIONS: src_test -> java-pkg-simple_src_test
debug: java-pkg_init: entering function, parameters: 
debug: java-pkg_switch-vm: entering function, parameters: 
debug: java-pkg_needs-vm: entering function, parameters: 
debug: depend-java-query:  NV_DEPEND:   
    >=virtual/jdk-1.8:*
    test? (
        dev-java/hamcrest-library:1.3
    )

    dev-java/hamcrest-core:1.3
 >=dev-java/java-config-2.2.0-r3 source? ( app-arch/zip )
debug: Using: openjdk-21
debug: java-pkg_setup-vm: entering function, parameters: 
debug: java-pkg_get-vm-vendor: entering function, parameters: 
debug: java-pkg_javac-args: entering function, parameters: 
debug: want source: 1.8
debug: want target: 1.8
debug: java-pkg_append_: entering function, parameters: LD_LIBRARY_PATH /usr/lib64/openjdk-21/lib/:/usr/lib64/openjdk-21/lib/server/
 * Using: openjdk-21
>>> Unpacking source...
>>> Unpacking junit-4.13.2.tar.gz to /var/tmp/portage/dev-java/junit-4.13.2/work
>>> Source unpacked in /var/tmp/portage/dev-java/junit-4.13.2/work
>>> Preparing source in /var/tmp/portage/dev-java/junit-4.13.2/work ...
./junit4-r4.13.2/lib/hamcrest-core-1.3.jar
./junit4-r4.13.2/lib/hamcrest-core-1.3-sources.jar
./junit4-r4.13.2/.mvn/wrapper/maven-wrapper.jar
>>> Source prepared.
>>> Configuring source in /var/tmp/portage/dev-java/junit-4.13.2/work ...
>>> Source configured.
>>> Compiling source in /var/tmp/portage/dev-java/junit-4.13.2/work ...
debug: java-pkg_gen-cp: entering function, parameters: JAVA_GENTOO_CLASSPATH
debug: java-pkg-simple_getclasspath: entering function, parameters: 
debug: java-pkg_getjars: entering function, parameters: --with-dependencies hamcrest-core-1.3
debug: hamcrest-core-1.3:/usr/share/hamcrest-core-1.3/lib/hamcrest-core.jar
debug: java-pkg_ensure-dep: entering function, parameters: hamcrest-core-1.3
debug: Matching against: /hamcrest-core(-1\.3(-[^:]+)?:0|(-[^:]+)?:1\.3)\b
debug: java-pkg_record-jar_: entering function, parameters: hamcrest-core-1.3
debug: CLASSPATH=/usr/share/hamcrest-core-1.3/lib/hamcrest-core.jar
debug: java-pkg-simple_prepend_resources: entering function, parameters: target/classes junit4-r4.13.2/src/main/resources
debug: ejavac: entering function, parameters: -d target/classes -encoding ISO-8859-1 -classpath /usr/share/hamcrest-core-1.3/lib/hamcrest-core.jar @sources.lst
debug: java-pkg_get-javac: entering function, parameters: 
debug: java-pkg_init-compiler_: entering function, parameters: 
debug: Read "" from /etc/java-config-2/build/compilers.conf
debug: java-pkg_javac-args: entering function, parameters: 
debug: want source: 1.8
debug: want target: 1.8
 * Verbose logging for "ejavac" function
 * Compiler executable: javac
 * Extra arguments: -source 1.8 -target 1.8
 * Complete command:
 * javac -source 1.8 -target 1.8 -d target/classes -encoding ISO-8859-1 -classpath /usr/share/hamcrest-core-1.3/lib/hamcrest-core.jar @sources.lst
javac -source 1.8 -target 1.8 -d target/classes -encoding ISO-8859-1 -classpath /usr/share/hamcrest-core-1.3/lib/hamcrest-core.jar @sources.lst
warning: [options] bootstrap class path not set in conjunction with -source 8
warning: [options] source value 8 is obsolete and will be removed in a future release
warning: [options] target value 8 is obsolete and will be removed in a future release
warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
junit4-r4.13.2/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);
                                               ^
junit4-r4.13.2/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);
                                                     ^
junit4-r4.13.2/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);
                                                               ^
junit4-r4.13.2/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);
                                                  ^
junit4-r4.13.2/src/main/java/junit/framework/TestResult.java:145: warning: [removal] ThreadDeath in java.lang has been deprecated and marked for removal
        } catch (ThreadDeath e) { // don't catch ThreadDeath by accident
                 ^
junit4-r4.13.2/src/main/java/org/junit/internal/runners/statements/FailOnTimeout.java:145: warning: [removal] isDaemon() in ThreadGroup has been deprecated and marked for removal
        if (!threadGroup.isDaemon()) {
                        ^
junit4-r4.13.2/src/main/java/org/junit/internal/runners/statements/FailOnTimeout.java:151: warning: [removal] setDaemon(boolean) in ThreadGroup has been deprecated and marked for removal
                threadGroup.setDaemon(true);
                           ^
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
4 errors
7 warnings
marcphilipp commented 8 months ago

Can you compile it with Java 8?

vaukai commented 8 months ago

Can you compile it with Java 8?

Java 8, Java 11,Java 17, all are fine. Only Java 21 fails.

marcphilipp commented 8 months ago

The ClassNotFoundException is declared as part of the constructor signature: https://github.com/junit-team/junit4/blob/0eb5ce72848d730da5bd6d42902fdd6a8a42055d/src/main/java/org/junit/runner/Result.java#L191-L198

vaukai commented 8 months ago

Dupe of https://github.com/junit-team/junit4/issues/1739. Sorry.