Bug 66064 - Tomcat 8.5.78 unit tests on JDK8 fails with: Unrecognized option: --add-opens=java.base/java.lang=ALL-UNNAMED
Summary: Tomcat 8.5.78 unit tests on JDK8 fails with: Unrecognized option: --add-opens...
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 8
Classification: Unclassified
Component: Meta (show other bugs)
Version: 8.5.78
Hardware: Sun Solaris
: P2 normal (vote)
Target Milestone: ----
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-05-13 08:15 UTC by Petr Sumbera
Modified: 2022-05-16 18:24 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Petr Sumbera 2022-05-13 08:15:00 UTC
I see these:

test-nio:
    [junit] Unrecognized option: --add-opens=java.base/java.lang=ALL-UNNAMED
    [junit] Error: Could not create the Java Virtual Machine.
    [junit] Error: A fatal exception has occurred. Program will exit.
    [junit] Running javax.el.TestArrayELResolver
    [junit] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0 sec
    [junit] Test javax.el.TestArrayELResolver FAILED (crashed)
    [junit] Unrecognized option: --add-opens=java.base/java.lang=ALL-UNNAMED
    [junit] Error: Could not create the Java Virtual Machine.
    [junit] Error: A fatal exception has occurred. Program will exit.
    [junit] Running javax.el.TestBeanELResolver
    [junit] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0 sec

--

$ java -version
java version "1.8.0_331"
Java(TM) SE Runtime Environment (build 1.8.0_331-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.331-b09, mixed mode)
Comment 1 Rainer Jung 2022-05-13 08:28:57 UTC
It should suffice to add the following lines to your own build.properties file:

opens.javalang=-Dnop
opens.javaio=-Dnop
opens.sunrmi=-Dnop
opens.javautil=-Dnop
opens.javautilconcurrent=-Dnop

You can add them before building or also just before running the test. They only apply to the unit test runs. The "nop" was chosen as any system property name that is likely not actually being used. It should remind one of a "no-operation".

The project switched to using JDK 11 during build (but the resulting TC 8.5 still runs on Java 7). Those switches above were introduced to still allow testing for older JDKs to ensure compatibility.

For testing with JDK 7 a few more adjustments are needed.

We should probably document this.

Regards,

Rainer
Comment 2 Mark Thomas 2022-05-13 08:31:03 UTC
Tomcat 8.5.x now requires Java 11 to build.

Minimum runtime version remains Java 7.

See BUILDING.txt in the root of the distribution.

It does appear that building.html needs to updated for all versions.
Comment 3 Petr Sumbera 2022-05-13 08:43:56 UTC
Aha. Thank you! I see it now:

https://github.com/apache/tomcat/commit/3b68fa6a4632592086cb9dc20118130cc7b9d16e
https://github.com/apache/tomcat/commit/1912714307925c82b1ee015d7644bba044acf1f9

With the workaround added into build.properties file I'm running unit testing now.

But still I used JDK 8 for the build without any problem. Is JDK 11 for the build really hard requirement now?
Comment 4 Mark Thomas 2022-05-16 16:09:59 UTC
The expectation is that Tomcat will be built with (at least) Java 11.

It will probably remain possible to build with Java 8 but at some point that might no longer be the case.
Comment 5 Christopher Schultz 2022-05-16 17:57:25 UTC
FWIW, all my Tomcat 8.5.x release testing is done by building-from-source with a Java 1.8 JVM and toolchain (and I'm the current release-manager for Tomcat 8.5.x). I use the exact technique Rainer detailed in comment #1.

I have a loose commitment to ensure Tomcat 8.5.x will be buildable by Java 1.8
Comment 6 Mark Thomas 2022-05-16 18:24:36 UTC
I've updated building.html for the next round of releases.

Fixed in:
- 10.1.x for 10.1.0-M16 onwards
- 10.0.x for 10.0.22 onwards
- 9.0.x for 9.0.64 onwards
- 8.5.x for 8.5.80 onwards