RFR: 8368467: [lworld] Add new flag generation for jimage to support preview mode [v7]
David Beaumont
duke at openjdk.org
Mon Oct 27 11:20:02 UTC 2025
> 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.
>
> Compare and review this against https://github.com/openjdk/valhalla/pull/1619.
David Beaumont has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 25 commits:
- General tidying after resync.
* tweaking tests for readability
* Fixing up after dependent PR changes
- Resquashing after sync.
* feedback and remove unused code
* new tests for ImageLocation
* Restoring lost changes and updating some comments.
* add system property guard to preview mode
* Remove TODOs now jimage version is bumped
* jimage writer changes to support preview mode.
- Merge branch 'jdk_8368333_java/squashed' into jdk_8368467_reader/squashed
- Rolled up changes after rebase.
* Removing package root flag based on feedback.
* Changing existing package flags during writing to match altered flag values.
* Feedback changes, and fixing some comments.
* Renaming slightly confusing "testEncoder" method.
* Fixing unit tests to use new constructor.
* Word smithing flags definitions.
* Add workaround until new image writing code is in
* Clarifying flag docs for /packages/xxx case
* Java ImageReader changes for preview mode
- Merge branch 'jdk_8366093_cpp/squashed' into jdk_8368333_java/squashed
- Reorganising to catch preview-only cases
- [[RESET BRANCH FOR MERGE]]
- [[RESET BRANCH FOR MERGE]]
- feedback and remove unused code
- Resync after dependent PR change.
* new tests for ImageLocation
* Restoring lost changes and updating some comments.
* add system property guard to preview mode
* Remove TODOs now jimage version is bumped
* jimage writer changes to support preview mode.
- ... and 15 more: https://git.openjdk.org/valhalla/compare/b22f6a47...86d1c928
-------------
Changes: https://git.openjdk.org/valhalla/pull/1621/files
Webrev: https://webrevs.openjdk.org/?repo=valhalla&pr=1621&range=06
Stats: 3844 lines in 35 files changed: 2234 ins; 405 del; 1205 mod
Patch: https://git.openjdk.org/valhalla/pull/1621.diff
Fetch: git fetch https://git.openjdk.org/valhalla.git pull/1621/head:pull/1621
PR: https://git.openjdk.org/valhalla/pull/1621
More information about the valhalla-dev
mailing list