On Fri, 29 May 2026 07:52:19 GMT, Xueming Shen <[email protected]> wrote:

> This fixes a regression from JDK-8377070 where `ImageResourcesTree` treated 
> every image entry path as a package hierarchy. That implicitly assumes 
> directory path segments cannot contain `.`, which is true for package paths 
> but not for ordinary resources such as 
> `META-INF/maven/com.google.code.findbugs/...`.
> 
> The fix handles non-preview `META-INF/` entries as resource paths, preserving 
> their directory names as-is and avoiding package inference for those 
> resources. `META-INF/preview/` continues to use the existing package-oriented 
> handling because those entries represent preview class/package content.
> 
> A regression test was added to `ImageReaderTest` with `META-INF` resources 
> containing dotted path segments, verifying resource lookup and directory 
> contents in both preview-enabled and preview-disabled modes.
> 
> This change was developed by @david-beaumont.
> 
> ---------
> - [x] I confirm that I make this contribution in accordance with the [OpenJDK 
> Interim AI Policy](https://openjdk.org/legal/ai).

src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageResourcesTree.java 
line 245:

> 243:             if (resPath.startsWith("META-INF/")) {
> 244:                 parentNode = getDirectoryNode("META-INF", parentNode);
> 245:                 if (!resPath.startsWith(PREVIEW_PREFIX)) {

A little note for myself :-) 

Before #31109:
    META-INF resource added to /modules literally;
    skipped only from /packages.

After #31109:
    META-INF resource incorrectly added to /modules as package-style path;
    skipped from /packages.

After #31318:
    META-INF resource added to /modules literally again;
    skipped from /packages.

 META-INF/preview/...:
     special preview namespace.  added under /modules/<m>/META-INF/preview/...;
      prefix stripped, then remaining path handled package-style;  resulting 
package links marked preview-only.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/31318#discussion_r3338189401

Reply via email to