[lworld] RFR: 8368333: [lworld] Add preview mode to ImageReader and JRT file-system [v7]

David Beaumont duke at openjdk.org
Fri Oct 24 14:24:55 UTC 2025


On Thu, 23 Oct 2025 15:48:50 GMT, Roger Riggs <rriggs at openjdk.org> wrote:

>> Hmm, I don't see a nice way to do this at runtime since you can't lookup string offsets by their value (as far as I can see).
>> 
>> It's no more fragile than the old code (which had hard-coded constants for "class" and "" (and wasn't self-checking their validity). At least now it's tested at build time.
>> 
>> If the version number matches it should be safe. I'll add a comment about how changing existing entries is problematic.
>
> Seems unlikely to mismatch.  
> ImageStringReader.match(offset, string, indxe) could be used to check the Strings or ImageStringReader.get(offset).

Trouble is, if the jimage is corrupt wrt the offsets, you cannot trust the offset, so `ImageStringReader.get(offset)` can't be trusted to be well defined.

The question you would have to ask at runtime is:
* what's the valid offset of this known string?
and not:
* what's the string at this (untrusted) offset.

The latter is just undefined if you can't trust the offset, and if you can trust the offset, you don't need to test it.
And I'd argue that if you can't trust one offset, you can't really trust any offsets and you're just broken already.

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

PR Review Comment: https://git.openjdk.org/valhalla/pull/1619#discussion_r2460246042


More information about the valhalla-dev mailing list