[lworld] RFR: 8377162: [lworld] getResourceAsStream() doesn't work in preview mode for exploded images [v5]

David Beaumont duke at openjdk.org
Mon Feb 23 14:48:13 UTC 2026


On Mon, 23 Feb 2026 14:36:15 GMT, David Beaumont <duke at openjdk.org> wrote:

>> test/jdk/jdk/internal/jrtfs/ClassResourcesParityTest.java line 74:
>> 
>>> 72:             String relPath = jrtClassFile.subpath(2, jrtClassFile.getNameCount()).toString();
>>> 73:             String fqn = relPath.substring(0, relPath.length() - CLASS_SUFFIX.length()).replace('/', '.');
>>> 74:             String baseName = fqn.substring(fqn.lastIndexOf('.') + 1);
>> 
>> This is fine, just FYI that JAVA_BASE.relativize(jrtClassFile) is another slicker way to get the relative path from /module/java.base to the resource.
>
> Hmm, good point. However I don't have the `/modules/<name>` path to hand here, so I still need to subpath() something. So it's
> 
> jrtClassFile.subpath(0, 2).relativize(jrtClassFile).toString();
> 
> vs
>             
> jrtClassFile.subpath(2, jrtClassFile.getNameCount()).toString();
> 
> Marginal win for readability.

Actually, that caused an exception:

            Path modRoot = jrtClassFile.subpath(0, 2);
            String relPath = modRoot.relativize(jrtClassFile).toString();

results in:

java.lang.IllegalArgumentException: Incorrect filesystem or path: /modules/java.base/com/sun/crypto/provider/AEADBufferedStream.class
        at java.base/jdk.internal.jrtfs.JrtPath.relativize(JrtPath.java:223)
        at java.base/jdk.internal.jrtfs.JrtPath.relativize(JrtPath.java:59)
        at ClassResourcesParityTest.testMatchesGetResourceAsStream(ClassResourcesParityTest.java:73)

So I'll stick with what I've got.

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

PR Review Comment: https://git.openjdk.org/valhalla/pull/2032#discussion_r2841250185


More information about the valhalla-dev mailing list