On Mon, 22 Jun 2026 13:50:19 GMT, Chen Liang <[email protected]> wrote:
> Good catch. Just curious why this worked if the resource was in another
> directory like in packages.
When `ImageReader` opens the image in preview mode, it scans `/packages` and
eagerly process packages that have preview content, caching preview resources
and preview-only directories for direct lookup.
That is why preview resources in package-like directories worked: later lookups
of `/modules/<module>/directory/file.txt`, or resource loading for those paths,
can hit the cached preview node.
A root-level preview resource is different. It has no package path; it belongs
to the empty package/module root resource directory. The empty package is
intentionally not represented under `/packages`, so the package-driven preview
pre-scan has no package entry that would trigger eager processing of
`/modules/<module>/META-INF/preview`.
This also means the current fix is incomplete. It fixes direct resource lookup
when it happens first, but it does not cover all node-cache orderings. If the
user first lists children of `/modules/<module>`, the module directory is
completed from the normal directory contents. A later
`findNode("/modules/<module>/file.txt")` still does not discover the
corresponding root-level preview resource...
-------------
PR Comment: https://git.openjdk.org/jdk/pull/31609#issuecomment-4770411665