On Mon, 20 Apr 2026 13:41:02 GMT, David Beaumont <[email protected]> wrote:
>>> `open("META-INF/preview/java/lang/Byte.class")` would be unusual but it
>>> will (at least in the lword) branch, locate the class bytes for the version
>>> of j.l.Byte compiled with preview features enabled.
>>
>> Exactly.
>>
>>> I'm not sure if you are suggesting this should also be hidden but do need
>>> to have a story on the consistently when the full list of resources are
>>> enumerated with `ModuleReader::list`.
>>
>> The story of consistency is what I'd suggest to improve (post JEP 401). If
>> `list` doesn't show it, then it should also not be possible to get the input
>> stream via `open`.
>
> `ModuleReader.open("META-INF/preview/java/lang/Byte.class")` should not also
> return the input stream to the preview classes as far as I am aware.
>
> Only the `JRTArchive` code even has access to the raw API and *everything*
> else goes via the `SystemImage` API with which it's not possible to get the
> preview versions of anything via their "raw" path.
>
> See (ImageReader) where *any* preview path is rejected immediately and
> prevents nodes for them ever existing:
>
> /**
> * Builds a node in the "/modules/..." namespace.
> *
> * <p>Called by {@link #findNode(String)} if a {@code /modules/...}
> node
> * is not present in the cache.
> */
> private Node buildAndCacheModulesNode(String name) {
> assert name.startsWith(MODULES_PREFIX + "/") : "Invalid module
> node name: " + name;
> if (isPreviewName(name)) {
> return null;
> }
Also note, this is all tested for (either in tests in the PR, or tests in
lworld which will come in with later PRs).
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/29414#discussion_r3111118433