On Wed, 22 Apr 2026 09:41:28 GMT, David Beaumont <[email protected]> wrote:
>> I'm not seeing the same behaviour with jshell. And what I'm seeing is
>> exactly what I expect to see.
>>
>>
>> [jdk/beta/open -> jimage_preview_mode]%
>> ../build/linux-x64/images/jdk/bin/jshell
>> | Welcome to JShell -- Version 27-internal
>> | For an introduction type: /help intro
>>
>> jshell> var mref = ModuleFinder.ofSystem().find("java.base").orElseThrow();
>> mref ==> [module java.base, location=jrt:/java.base]
>>
>> jshell> var bytePreviewResource = "META-INF/preview/java/lang/Byte.class";
>> bytePreviewResource ==> "META-INF/preview/java/lang/Byte.class"
>>
>> jshell> var bytePreview = mref.open().list().filter(n ->
>> n.equals(bytePreviewResource)).toList();
>> bytePreview ==> []
>>
>> jshell> var inStream = mref.open().find(bytePreviewResource).orElseThrow();
>> | Exception java.util.NoSuchElementException: No value present
>> | at Optional.orElseThrow (Optional.java:381)
>> | at do_it$Aux (#4:1)
>> | at (#4:1)
>>
>> jshell> var inStream =
>> java.lang.Object.class.getResourceAsStream(bytePreviewResource);
>> inStream ==> null
>>
>> jshell> var inStream = java.lang.Object.class.getResourceAsStream("/" +
>> bytePreviewResource);
>> inStream ==> null
>>
>> jshell> var mref = ModuleFinder.ofSystem().find("java.base").orElseThrow();
>> mref ==> [module java.base, location=jrt:/java.base]
>>
>> jshell> var inStream = mref.open().open(bytePreviewResource).orElseThrow();
>> | Exception java.util.NoSuchElementException: No value present
>> | at Optional.orElseThrow (Optional.java:381)
>> | at do_it$Aux (#8:1)
>> | at (#8:1)
>>
>>
>> (that's with this PR patched into head as it would be submitted now).
>>
>> Obviously this is not the final state of things, and there's support for
>> "exploded" images to be added, along with the plumbing of the compiler
>> flags, so while this is a transient state, it's exactly what I expect to see.
>
> Nevermind, of course there are no preview resources built into the jimage yet
> for mainline.
Okay, I've found the bug, it was in code which avoided using the node cache
purely for performance reasons and was *defined* to behave like the node cache
(in which preview nodes are invisible), but it wasn't properly accounting for
preview resource paths. I'll push a fix with updated tests shortly.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/29414#discussion_r3123201434