Skip to content

Conversation

@david-beaumont
Copy link
Contributor

@david-beaumont david-beaumont commented Nov 12, 2025

Rewrite of VerifyJimage test to fix several severe issues.

This test runs in two modes, one of which is completely broken (but claims to pass) and the other which currently works but must be made compatible with up-coming preview mode changes from Valhalla.

Issue 1: Broken file comparison

This is a mode not currently run by default, but very very broken if it is run manually. It creates incorrect entry names for looking into the jimage and then ignores non existent entries without raising a failure. This code must have been broken since the introduction of BasicImageReader and the modules system.

This is the larger part of the VerifyJimage code, and it was never going to be worth keeping much of the existing code, so I wrote a new nested class (DirectoryContentVerifier) to encapsulate it.

Importantly, this version now checks false positives and false negatives for file comparison, ensuring that "true failure" cannot be silently ignored. The set of entries in the jimage which have been handled is recorded, and a check is made that all entries have either been tested or explicitly ignored.

Issue 2: Use of BasicImageReader for class file reading

A relative small part of the original code, this mode was reading class names via BasicImageReader and attempting to load them. This approach works now, but will fail when preview mode is introduced since preview versions of classes must be loaded when the JVM is run in preview mode.

The best way to get "the current set of classes in the jimage" is to enumerate the jrt:/ file-system for the runtime image (which will account for preview mode when it's introduced). So the new code in ClassLoadingVerifier does this.

Issue 3: File comparison mode was never run by default

This is likely why the broken file comparison mode wasn't discovered for years. I added two test stanzas to VerifyJimage, so that both modes are run (if possible). Some care is needed because in CI testing there are no module directories for the file comparison mode, and this should not cause a test failure.


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-8371591: VerifyJimage test incorrectly skips all tests when comparing directory structure (Bug - P3)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 28265

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Nov 12, 2025

👋 Welcome back david-beaumont! A progress list of the required criteria for merging this PR into pr/28263 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 Nov 12, 2025

@david-beaumont This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8371591: VerifyJimage test incorrectly skips all tests when comparing directory structure

Reviewed-by: rriggs

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 17 new commits pushed to the master branch:

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@RogerRiggs) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk bot added the core-libs core-libs-dev@openjdk.org label Nov 12, 2025
@openjdk
Copy link

openjdk bot commented Nov 12, 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 the rfr Pull request is ready for review label Nov 12, 2025
@mlbridge
Copy link

mlbridge bot commented Nov 12, 2025

Webrevs

boolean shouldVerify(Path path) {
// Use the entry name because we know it uses the '/' separator.
String entryName = getEntryName(path);
return Files.isRegularFile(path)
Copy link
Contributor Author

@david-beaumont david-beaumont Nov 12, 2025

Choose a reason for hiding this comment

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

I have no idea if there's a better definition of "what is a marker file", but this logic was sufficient to prevent issues. Same for the other two predicates. I started by letting everything through and added sensible looking clauses until it passed.

static final class ClassLoadingVerifier extends VerifyJimage {
private static final String CLASS_SUFFIX = ".class";

static class JImageReader extends BasicImageReader {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This being a subclass of BasicImageReader means it was reading the "raw" unmapped entries, meaning that in preview mode it will try and load the non-preview version of the class from the reader in a VM that's using preview mode classes. Using JRT file system, which is preview mode aware for the current runtime, always gives you the "right" choice of class bytes for class loading.

static final class ClassLoadingVerifier extends VerifyJimage {
private static final String CLASS_SUFFIX = ".class";

static class JImageReader extends BasicImageReader {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This being a subclass of BasicImageReader means it was reading the "raw" unmapped entries, meaning that in preview mode it will try and load the non-preview version of the class from the reader in a VM that's using preview mode classes. Using JRT file system, which is preview mode aware for the current runtime, always gives you the "right" choice of class bytes for class loading.

@openjdk-notifier openjdk-notifier bot changed the base branch from pr/28263 to master November 12, 2025 15:52
@openjdk-notifier
Copy link

The parent pull request that this pull request depends on has now been integrated and the target branch of this pull request has been updated. This means that changes from the dependent pull request can start to show up as belonging to this pull request, which may be confusing for reviewers. To remedy this situation, simply merge the latest changes from the new target branch into this pull request by running commands similar to these in the local repository for your personal fork:

git checkout jdk_8371591_verify
git fetch https://git.openjdk.org/jdk.git master
git merge FETCH_HEAD
# if there are conflicts, follow the instructions given by git merge
git commit -m "Merge master"
git push

}
} catch (IOException e) {
throw new UncheckedIOException(e);
System.out.println("Loading " + cn);
Copy link
Contributor

Choose a reason for hiding this comment

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

Printing the successful class names isn't very useful, (even if it was previously).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair point, will remove that.

Copy link
Contributor

@RogerRiggs RogerRiggs left a comment

Choose a reason for hiding this comment

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

Looks good.

@david-beaumont
Copy link
Contributor Author

/integrate

@openjdk
Copy link

openjdk bot commented Nov 14, 2025

@david-beaumont This pull request has not yet been marked as ready for integration.

Copy link
Contributor

@RogerRiggs RogerRiggs left a comment

Choose a reason for hiding this comment

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

Still looks good.

@openjdk openjdk bot added ready Pull request is ready to be integrated and removed ready Pull request is ready to be integrated labels Nov 14, 2025
@david-beaumont
Copy link
Contributor Author

/integrate

@openjdk
Copy link

openjdk bot commented Nov 14, 2025

@david-beaumont This pull request has not yet been marked as ready for integration.

@kevinrushforth
Copy link
Member

@david-beaumont Alan modified the title of the JBS bug. Update the PR title to match, then Skara will mark it as ready.

@david-beaumont david-beaumont changed the title 8371591: VerifyJimage tool incorrectly skips all tests when comparing directory structure 8371591: VerifyJimage test incorrectly skips all tests when comparing directory structure Nov 14, 2025
@openjdk openjdk bot added the ready Pull request is ready to be integrated label Nov 14, 2025
@david-beaumont
Copy link
Contributor Author

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Nov 14, 2025
@openjdk
Copy link

openjdk bot commented Nov 14, 2025

@david-beaumont
Your change (at version 6a4cb62) is now ready to be sponsored by a Committer.

@RogerRiggs
Copy link
Contributor

/sponsor

@openjdk
Copy link

openjdk bot commented Nov 14, 2025

Going to push as commit 6e7eaf4.
Since your change was applied there have been 17 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Nov 14, 2025
@openjdk openjdk bot closed this Nov 14, 2025
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review sponsor Pull request is ready to be sponsored labels Nov 14, 2025
@openjdk
Copy link

openjdk bot commented Nov 14, 2025

@RogerRiggs @david-beaumont Pushed as commit 6e7eaf4.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core-libs core-libs-dev@openjdk.org integrated Pull request has been integrated

Development

Successfully merging this pull request may close these issues.

3 participants