Skip to content

8365436: ImageReaderTest fails when jmods directory not present #26773

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

david-beaumont
Copy link
Contributor

@david-beaumont david-beaumont commented Aug 14, 2025

Switched from TestSkippedException (not honoured by JUnit) to TestAbortedException (via Assumptions class) to avoid false negative test "failure". Note that now, the test is either shown as skipped, or passed, depending on which report is being looked at. Tweaked error message slightly since using an "exploded image" isn't the only cause.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8365436: ImageReaderTest fails when jmods directory not present (Bug - P4)

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/26773/head:pull/26773
$ git checkout pull/26773

Update a local copy of the PR:
$ git checkout pull/26773
$ git pull https://git.openjdk.org/jdk.git pull/26773/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 26773

View PR using the GUI difftool:
$ git pr show -t 26773

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/26773.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Aug 14, 2025

👋 Welcome back david-beaumont! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Aug 14, 2025

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk
Copy link

openjdk bot commented Aug 14, 2025

@david-beaumont The following label will be automatically applied to this pull request:

  • core-libs

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added core-libs [email protected] rfr Pull request is ready for review labels Aug 14, 2025
@mlbridge
Copy link

mlbridge bot commented Aug 14, 2025

Webrevs

// '--generate-linkable-runtime' was used to build the runtime).
// This may be reporting as a skipped test, or a pass, depending
// on how the test was run.
Assumptions.assumeTrue(helper != null, "Cannot create test helper (no jimage file)");
Copy link
Contributor

@AlanBateman AlanBateman Aug 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a jimage file, Helper.newHelper is returning null because there are no packaged modules in the runtime image (= no jmods directory).

In passing, tests.Helper is the supporting class for the jlink tests. We should rename it or create a sub-directory in test/jdk/tools/lib/tests as the location/naming just won't work for this very specific class.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other PR on the bug (https://github.com/openjdk/jdk/pull/26774/files) changes the comment.
Happy for a more specific wording though.
This PR is likely redundant now.

Copy link
Contributor

@jerboaa jerboaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest to make the test run on as many scenarios as possible. This patch seems to work for me on a JEP 493-enabled build:

diff --git a/test/jdk/jdk/internal/jimage/ImageReaderTest.java b/test/jdk/jdk/internal/jimage/ImageReaderTest.java
index 62281151126..14c5f8eac21 100644
--- a/test/jdk/jdk/internal/jimage/ImageReaderTest.java
+++ b/test/jdk/jdk/internal/jimage/ImageReaderTest.java
@@ -25,6 +25,7 @@
 import jdk.internal.jimage.ImageReader.Node;
 import jdk.test.lib.compiler.InMemoryJavaCompiler;
 import jdk.test.lib.util.JarBuilder;
+import jdk.tools.jlink.internal.LinkableRuntimeImage;
 import org.junit.jupiter.api.Assumptions;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.TestInstance;
@@ -55,6 +56,7 @@
  * @summary Tests for ImageReader.
  * @modules java.base/jdk.internal.jimage
  *          jdk.jlink/jdk.tools.jimage
+ *          jdk.jlink/jdk.tools.jlink.internal
  * @library /test/jdk/tools/lib
  *          /test/lib
  * @build tests.*
@@ -216,7 +218,8 @@ public String toString() {
     private static Helper getHelper() {
         Helper helper;
         try {
-            helper = Helper.newHelper();
+            boolean isLinkableRuntime = LinkableRuntimeImage.isLinkableRuntime();
+            helper = Helper.newHelper(isLinkableRuntime);
         } catch (IOException e) {
             throw new RuntimeException(e);
         }

The comments seem wrong as Alan pointed out.

throw new TestSkippedException("Cannot create test helper (exploded image?)");
}
return helper;
helper = Helper.newHelper();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
helper = Helper.newHelper();
boolean isLinkableRuntime = LinkableRuntimeImage.isLinkableRuntime();
helper = Helper.newHelper(isLinkableRuntime);

This will make the test run (not abort) for JEP 493-enabled builds.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this was done for https://github.com/openjdk/jdk/pull/26774/files once I knew about it and could patch in the extra modules line.

@jerboaa
Copy link
Contributor

jerboaa commented Aug 14, 2025

I'm not sure why you've created another PR for the same issue, but I think this should get closed.

@david-beaumont
Copy link
Contributor Author

I'm closing this alternate PR, please review #26774 instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core-libs [email protected] rfr Pull request is ready for review
Development

Successfully merging this pull request may close these issues.

3 participants