From 8e3d2e66ce974d4fdd2abaa0bcf3ead261065b09 Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Sat, 21 Nov 2026 00:12:12 +0000 Subject: [PATCH] Build the Java models library with JDK 22 and newer The java-models-library submodule did not compile with JDK 22 and newer: javac rejects the statement in the constructor of the models' java.lang.Object with -source 8 ("flexible constructors is not supported"), and JDK 24 removed ClassLoader.checkClassLoaderPermission, which the models' java.lang.Class called. Ubuntu 26.04, and with it GitHub's ubuntu-latest runners, default to JDK 25, so that the CodeQL workflow currently fails to build JBMC. Update the submodule to a commit that applies the fix of diffblue/java-models-library#49 to the version of the models that we use. It only changes these two files, and (built with JDK 21) the bytecode differs only in the constructor of Object no longer storing 0 (the default value) to cproverMonitorCount, in the removed call, and in constant-pool indices. Updating to the current master of the models instead would also bring in new models, with which more than 100 JBMC regression tests fail (e.g., as Class.forName now fails an assertion for classes that are not modelled). With models built by JDK 25, all JBMC, janalyzer, jdiff and Java unit tests pass. Update COMPILING.md, which said that JDK 22 and newer do not work. Co-authored-by: Kiro --- COMPILING.md | 26 +++++++++++--------------- jbmc/lib/java-models-library | 2 +- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/COMPILING.md b/COMPILING.md index f803f8b418d5..7c69301ae9e4 100644 --- a/COMPILING.md +++ b/COMPILING.md @@ -167,12 +167,10 @@ We assume that you have a Debian/Ubuntu or Red Hat-like distribution. ``` dnf install java-1.8.0-openjdk-devel maven jq ``` - JBMC can be built with JDK versions 8 through 21. JDK 22 and newer fail to - compile the Java models library in `jbmc/lib/java-models-library`. The - supported JDK does not need to be the system-wide default. If the default - JDK is newer than 21, set `JAVA_HOME` to a supported JDK and prepend its - `bin` directory to `PATH` in the shell that runs the build. For example, - on Debian/Ubuntu on x86-64: + JBMC can be built with JDK 8 or newer (versions up to 25 are known to + work). The JDK does not need to be the system-wide default: to use another + one, set `JAVA_HOME` to it and prepend its `bin` directory to `PATH` in the + shell that runs the build. For example, on Debian/Ubuntu on x86-64: ``` export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 export PATH="$JAVA_HOME/bin:$PATH" @@ -184,7 +182,7 @@ We assume that you have a Debian/Ubuntu or Red Hat-like distribution. java -version javac -version ``` - Both commands should report a version between 1.8 (that is, 8) and 21. + Both commands should report a version of 1.8 (that is, 8) or newer. 2. As a user, get the CBMC source via ``` @@ -227,11 +225,10 @@ Follow these instructions: make -C src ``` 4. To compile JBMC, you additionally need Maven 3, which has to be installed - manually, and a JDK with a version between 8 and 21. JDK 22 and newer fail - to compile the Java models library. Homebrew's `maven` package uses the - newest Homebrew OpenJDK unless `JAVA_HOME` is set, so set `JAVA_HOME` to a - supported JDK in the shell that runs the build. `/usr/libexec/java_home -V` - lists the JDKs that macOS knows about. Then do + manually, and JDK 8 or newer. Homebrew's `maven` package uses the newest + Homebrew OpenJDK unless `JAVA_HOME` is set; to use another JDK, set + `JAVA_HOME` to it in the shell that runs the build. + `/usr/libexec/java_home -V` lists the JDKs that macOS knows about. Then do ``` make -C jbmc/src setup-submodules make -C jbmc/src @@ -272,9 +269,8 @@ Maven 3 manually. ``` pkg install openjdk8 wget maven ``` - JBMC can be built with JDK versions 8 through 21, but not with JDK 22 or - newer. If the default JDK is newer than 21, select OpenJDK 8 in the shell - that runs the build: + JBMC can be built with JDK 8 or newer. To select OpenJDK 8 in the shell + that runs the build, if it is not the default: ``` export JAVA_HOME=/usr/local/openjdk8 export PATH="$JAVA_HOME/bin:$PATH" diff --git a/jbmc/lib/java-models-library b/jbmc/lib/java-models-library index c7835345cf63..8874d77d7ba6 160000 --- a/jbmc/lib/java-models-library +++ b/jbmc/lib/java-models-library @@ -1 +1 @@ -Subproject commit c7835345cf635279cf59f4a286c05538f8026bd8 +Subproject commit 8874d77d7ba637cc4d460963a93029f8a14408e3