RFR: 8365436: ImageReaderTest fails when jmods directory not present

Severin Gehwolf sgehwolf at openjdk.org
Thu Aug 14 09:54:13 UTC 2025


On Thu, 14 Aug 2025 09:00:24 GMT, David Beaumont <duke at openjdk.org> wrote:

> 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.

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.

test/jdk/jdk/internal/jimage/ImageReaderTest.java line 219:

> 217:         Helper helper;
> 218:         try {
> 219:             helper = Helper.newHelper();

Suggestion:

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


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

-------------

Changes requested by sgehwolf (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/26773#pullrequestreview-3119903344
PR Review Comment: https://git.openjdk.org/jdk/pull/26773#discussion_r2276140933


More information about the core-libs-dev mailing list