On Wed, 22 Apr 2026 13:31:40 GMT, David Beaumont <[email protected]> wrote:
> Added correct checks to "fast path" read methods in ImageReader to avoid > module readers being able to see preview resources. > > --------- > - [x] I confirm that I make this contribution in accordance with the [OpenJDK > Interim AI Policy](https://openjdk.org/legal/ai). src/java.base/share/classes/jdk/internal/jimage/ImageReader.java line 486: > 484: if (node == null) { > 485: ImageLocation loc = null; > 486: if (previewMode) { Note that while there is a 2nd lookup here, it's only in preview mode (for which we are less worried about performance). There are ways to have a single lookup which I prototyped a while ago, but it's either a non-trivial change to how hashcodes are constructed, or a change to the jimage file format (either can work). test/jdk/jdk/internal/jimage/ImageReaderTest.java line 149: > 147: }) > 148: public void testResource_present(String modName, String resPath) > throws IOException { > 149: for (PreviewMode mode : List.of(PreviewMode.ENABLED, > PreviewMode.DISABLED)) { Decided it was worth having both modes tested here. ------------- PR Review Comment: https://git.openjdk.org/valhalla/pull/2354#discussion_r3124321115 PR Review Comment: https://git.openjdk.org/valhalla/pull/2354#discussion_r3124330401
