Try to create an image containing two modules, each with an
`OSGI-INF/MANIFEST.MF` resource. Although `OSGI_INF` is a non-package resource
directory, `jlink` fails with:
java.lang.IllegalStateException: Multiple modules contain non-empty package:
OSGI-INF
at
jdk.jlink/jdk.tools.jlink.internal.ImageResourcesTree$PackageNode.<init>(ImageResourcesTree.java:144)
at
jdk.jlink/jdk.tools.jlink.internal.ImageResourcesTree$Tree.lambda$buildTree$1(ImageResourcesTree.java:219)
at java.base/java.util.TreeMap.forEach(TreeMap.java:1318)
at
jdk.jlink/jdk.tools.jlink.internal.ImageResourcesTree$Tree.buildTree(ImageResourcesTree.java:211)
at
jdk.jlink/jdk.tools.jlink.internal.ImageResourcesTree$Tree.<init>(ImageResourcesTree.java:182)
at
jdk.jlink/jdk.tools.jlink.internal.ImageResourcesTree.<init>(ImageResourcesTree.java:457)
at
jdk.jlink/jdk.tools.jlink.internal.ImageFileCreator.generateJImage(ImageFileCreator.java:272)
at
jdk.jlink/jdk.tools.jlink.internal.ImageFileCreator.writeImage(ImageFileCreator.java:196)
at
jdk.jlink/jdk.tools.jlink.internal.ImageFileCreator.create(ImageFileCreator.java:127)
The problem is that `ImageResourcesTree.Tree.buildTree()` excludes only the
empty package and `META-INF` paths when populating `/packages`. It does not
check whether the remaining names are valid package names.
The proposed fix is to exclude all invalid package names from `/packages` while
preserving their resources in the image.
---------
- [x] I confirm that I make this contribution in accordance with the [OpenJDK
Interim AI Policy](https://openjdk.org/legal/ai).
-------------
Commit messages:
- 8393242: jlink fails with "Multiple modules contain non-empty package" for a
non-package resource directory in more than one module
Changes: https://git.openjdk.org/jdk/pull/33162/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=33162&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8393242
Stats: 116 lines in 2 files changed: 115 ins; 0 del; 1 mod
Patch: https://git.openjdk.org/jdk/pull/33162.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/33162/head:pull/33162
PR: https://git.openjdk.org/jdk/pull/33162