valhalla icon indicating copy to clipboard operation
valhalla copied to clipboard

8368467: [lworld] Add new flag generation for jimage to support preview mode

Open david-beaumont opened this issue 1 month ago • 3 comments

Adds support for writing preview related flags into jimage files.

Preview mode is complex. It's not nearly as simple as "does something in /modules/xxx/... have an entry in /modules/xxx/META-INF/preview/...".

Specific issues include:

Supporting preview-only resources without forcing a double lookup on everything. Changing the set of entries in /packages/xxx directories to account for preview only packages in some modules. Minimising the work done during image reader initialization to only need to process the small number of preview resources (rather than scanning the whole file to look for them). The new flags added by this code address these issues, but calculating them correctly with only minor adjustments to the existing code was not feasible, it just became a lot larger and very complex.

To address this, a new type (ModuleReference) is introduced to track and then merge information about packages seen in each module. This allows a much simpler inner loop for processing resource paths when building the node tree, combined with a subsequent merging stage to produce the final package information for each module.

Not that since ModuleReference is needed during jimage reading, that class is already present in the previous PR on which this is based, but it starts to be used to calculate the module flags in this PR.

This PR can also adds the ImageReader unit tests for preview mode, which rely on being able to generate jimage files with preview mode flags in.


Progress

  • [x] Change must not contain extraneous whitespace

Issue

  • JDK-8368467: [lworld] Add new flag generation for jimage to support preview mode (Sub-task - P3)

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 1718

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/valhalla/pull/1718.diff

Using Webrev

Link to Webrev Comment

david-beaumont avatar Nov 04 '25 17:11 david-beaumont

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

bridgekeeper[bot] avatar Nov 04 '25 17:11 bridgekeeper[bot]

@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:

8368467: [lworld] Add new flag generation for jimage to support preview mode

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 no new commits pushed to the lworld branch. If another commit should be pushed before you perform the /integrate command, your PR will be automatically rebased. If you prefer to avoid any potential 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[bot] avatar Nov 04 '25 17:11 openjdk[bot]

Sorry about the test failures, I'd left the DISABLE_PREVIEW_PATCHING system property in the wrong state. It should all work now. I fixed the method rename to forPackageIn(<module>...) because I strongly feel it's better than forPackage(<module>...) which I think just leaves the reader wondering why a package name isn't passed here.

david-beaumont avatar Nov 05 '25 18:11 david-beaumont

Is the failure of Test tools/jimage/JImageExtractTest.java expected?

RogerRiggs avatar Nov 06 '25 03:11 RogerRiggs

I hadn't noticed tools/jimage/JImageExtractTest.java was failing. Investigating now. Thanks.

david-beaumont avatar Nov 06 '25 12:11 david-beaumont

/integrate

david-beaumont avatar Nov 07 '25 13:11 david-beaumont

@david-beaumont Since your change was applied there have been 105 commits pushed to the lworld branch:

  • a0ec2441494f9e77b3a8a3db90358db239b27b4d: 8367244: [lworld] C2 compilation fails with assert "no node with a side effect"
  • a74780818f624c574adfe3c3380996679ba93fd7: Merge jdk
  • 17fd801b24162dfbac6d4e63ef5048a0fb146074: 8370807: G1: Improve region attribute table method naming
  • ... and 102 more: https://git.openjdk.org/valhalla/compare/a6d6cb8b9107cc6f8aeb28d5547cec9a5e58f711...lworld

It was not possible to rebase your changes automatically. Please merge lworld into your branch and try again.

openjdk[bot] avatar Nov 07 '25 13:11 openjdk[bot]

/integrate

david-beaumont avatar Nov 07 '25 16:11 david-beaumont

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

openjdk[bot] avatar Nov 07 '25 16:11 openjdk[bot]

/sponsor

RogerRiggs avatar Nov 11 '25 13:11 RogerRiggs

Going to push as commit 72539b57d088940bc18185d1658db6c89f4033fc. Since your change was applied there have been 4 commits pushed to the lworld branch:

  • a680c717f3204d2f878944b724c4a78560e4f913: 8370886: [lworld] 8369296 partially reverted for resolving static get/put field
  • f57d72f59472269d3b37a81b591ca236e0a03926: 8371560: [lworld] Disable check_symmetrical until JDK-8332406 is fixed
  • a180fefdd8f427c647f3a4f3a4bc937207d1fe72: 8371398: [lworld] runtime/valhalla/inlinetypes/FlatArrayCopyingTest.java#g1 fails due to lack of UnlockDiagnosticVMOptions
  • ... and 1 more: https://git.openjdk.org/valhalla/compare/a0ec2441494f9e77b3a8a3db90358db239b27b4d...lworld

Your commit was automatically rebased without conflicts.

openjdk[bot] avatar Nov 11 '25 13:11 openjdk[bot]

@RogerRiggs @david-beaumont Pushed as commit 72539b57d088940bc18185d1658db6c89f4033fc.

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

openjdk[bot] avatar Nov 11 '25 13:11 openjdk[bot]