← Back to issue list

Java plugin tests fail if you have a JDK newer than 17 but != 21

View original Github issue

Metadata

Project
craft-parts
Number
#985
Type
issue
State
closed
Author
lengau
Labels
—
Created
Updated
Closed

Current evaluation

Fixed by merged PR #986 (commit d36a93d5, 'fix(tests): don't fail if you have additional JREs'), making Java plugin tests tolerate extra installed JDKs like 25 instead of asserting JAVA_HOME.

Resolution: closed resolved

Reason: PR #986 'fix(tests): don't fail if you have additional JREs' was merged, landing as commit d36a93d5 in craft-parts and explicitly closing issue #985. The change alters tests/unit/plugins/test_java_plugin.py (seen in the file's history immediately after a3b9cdab 'feat: java plugin should set JAVA_HOME').

Evaluated by: mr-cal-bot

No scores available.

Issue body

### Bug Description If you have a JDK other than 21 that's newer than java 17, the tests fail. ### To Reproduce ``` $ dpkg -l|grep openjdk ii openjdk-17-jdk-headless:amd64 17.0.14~6ea-1 amd64 OpenJDK Development Kit (JDK) (headless) ii openjdk-17-jre-headless:amd64 17.0.14~6ea-1 amd64 OpenJDK Java runtime, using Hotspot JIT (headless) ii openjdk-21-jdk-headless:amd64 21.0.6~6ea-1ubuntu2 amd64 OpenJDK Development Kit (JDK) (headless) ii openjdk-21-jre-headless:amd64 21.0.6~6ea-1ubuntu2 amd64 OpenJDK Java runtime, using Hotspot JIT (headless) ii openjdk-25-jdk:amd64 25~4ea-1 amd64 OpenJDK Development Kit (JDK) ii openjdk-25-jdk-headless:amd64 25~4ea-1 amd64 OpenJDK Development Kit (JDK) (headless) ii openjdk-25-jre:amd64 25~4ea-1 amd64 OpenJDK Java runtime, using Hotspot JIT ii openjdk-25-jre-headless:amd64 25~4ea-1 amd64 OpenJDK Java runtime, using Hotspot JIT (headless) ``` ``` pytest tests/unit/plugins/test_java_plugin.py::test_java_plugin_jre_21 ``` ### part yaml ```shell n/a ``` ### Relevant log output ```shell $ pytest tests/unit/plugins/test_java_plugin.py::test_java_plugin_jre_21 ========================================================================================= test session starts ========================================================================================= platform linux -- Python 3.11.10, pytest-8.3.4, pluggy-1.5.0 rootdir: /home/lengau/Work/Code/craft-parts configfile: pyproject.toml plugins: subprocess-1.5.3, cov-5.0.0, requests-mock-1.12.1, check-2.4.1, hypothesis-6.124.2, mock-3.14.0 collected 1 item tests/unit/plugins/test_java_plugin.py F [100%] ============================================================================================== FAILURES =============================================================================================== _______________________________________________________________________________________ test_java_plugin_jre_21 _______________________________________________________________________________________ part_info = <craft_parts.infos.PartInfo object at 0x7deb502fab90>, mocker = <pytest_mock.plugin.MockerFixture object at 0x7deb502e6510> def test_java_plugin_jre_21(part_info, mocker): orig_check_java = JavaPlugin._check_java def _check_java(self, javac: str): if "21" in javac: return None, "" return orig_check_java(self, javac) mocker.patch.object(JavaPlugin, "_check_java", _check_java) properties = MavenPlugin.properties_class.unmarshal({"source": "."}) plugin = MavenPlugin(properties=properties, part_info=part_info) env = plugin.get_build_environment() assert len(env) == 1 > assert "17" in env["JAVA_HOME"] E AssertionError: assert '17' in '/usr/lib/jvm/java-25-openjdk-amd64' /home/lengau/Work/Code/craft-parts/tests/unit/plugins/test_java_plugin.py:61: AssertionError ======================================================================================= short test summary info ======================================================================================= FAILED tests/unit/plugins/test_java_plugin.py::test_java_plugin_jre_21 - AssertionError: assert '17' in '/usr/lib/jvm/java-25-openjdk-amd64' ```

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha — closed resolved Fixed by merged PR #986 (commit d36a93d5, 'fix(tests): don't fail if you have additional JREs'), making Java plugin tests tolerate extra installed JDKs like 25 instead of asserting JAVA_HOME.
stealth/space-bunny-alpha — closed resolved Fixed by merged PR #986 (commit d36a93d5): Java plugin tests now tolerate additional installed JREs instead of failing on unexpected JAVA_HOME versions.
qwen/qwen3.6-35b-a3b — — Closed without resolution. The test fails when a JDK newer than 17 but not 21 is installed, causing JAVA_HOME assertions to expect version 17. No fix or follow-up pull request was provided.
qwen/qwen3.6-35b-a3b — — Closed without resolution. Tracked externally via Jira ticket CRAFT-3997. Test failures occur when JDK versions newer than 17 but not 21 are installed, causing assertion errors in Java plugin tests.
qwen/qwen3.6-35b-a3b — — Closed without a fix. Synced to Jira CRAFT-3997. No PRs merged to address the JDK version mismatch causing Java plugin test failures.
qwen3.6-35b-a3b-mtp-q6 — — Closed without a documented fix or merge. The Java plugin test failure for JDK versions newer than 17 but not 21 remains unresolved, indicating the issue was likely abandoned or handled externally.

Update history

No update history recorded yet.

Related work

  • Likely Fixed By: canonical/craft-parts#986 (confidence 97%)

    Merged PR titled 'fix(tests): don't fail if you have additional JREs', commit 50af1b91/d36a93d5, which closes #985.

  • Caused By: canonical/craft-parts#895 (confidence 55%)

    Commit a3b9cdab 'feat: java plugin should set JAVA_HOME (#895)' introduced the JAVA_HOME-dependent test assertions that fail on unexpected JDK versions.

Related issues

Issue Project State Summary Similarity
#986 fix(tests): don't fail if you have additional JREs craft-parts merged Merged PR #986 as 50af1b91 (change d36a93d5), updating Java plugin tests to tolerate additional installed JREs and fixing #985.
80%
#1513 Make Java plugins work on Ubuntu 26.04 craft-parts open Triaged: make Java plugin version-sensitive tests pass on Ubuntu 26.04 (Resolute, default OpenJDK 25). Tracked as CRAFT-5065 and fixed by merged PR #1530 (commit da6b596e), which enabled the Java plugin tests on resolute.
70%