Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions test/jdk/jdk/internal/jimage/ImageReaderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
import jdk.internal.jimage.ImageReader.Node;
import jdk.test.lib.compiler.InMemoryJavaCompiler;
import jdk.test.lib.util.JarBuilder;
import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import org.opentest4j.TestSkippedException;
import tests.Helper;
import tests.JImageGenerator;

Expand Down Expand Up @@ -214,15 +214,18 @@ public String toString() {

/// Returns the helper for building JAR and jimage files.
private static Helper getHelper() {
Helper helper;
try {
Helper helper = Helper.newHelper();
if (helper == null) {
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.

} catch (IOException e) {
throw new RuntimeException(e);
}
// Gracefully skip if there's no jimage to work with (e.g. if
// '--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.

return helper;
}

/// Loads and performs actions on classes stored in a given `ImageReader`.
Expand Down