On Mon, 20 Apr 2026 09:35:26 GMT, Severin Gehwolf <[email protected]> wrote:

>>> Shouldn't ModuleReader.open("META-INF/preview/java/lang/Byte.class") then 
>>> also not return the input stream to the preview classes?
>> 
>> META-INF/preview won't be used until JEP 401 integrates.
>> 
>> The important usage at runtime is `open("java/lang/Byte.class")`,  which we 
>> would see with code like `Byte.class.getResourceAsStream("Byte.class")`.  If 
>> there is version of the class file in META-INF/preview then it will locate 
>> that when preview features are enabled.
>> 
>> `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. 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`.
>
>> `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.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/29414#discussion_r3111066022

Reply via email to