RFR: 8315130: java.lang.IllegalAccessError when processing classlist to create CDS archive [v8]

Calvin Cheung ccheung at openjdk.org
Thu Apr 17 05:44:57 UTC 2025


On Wed, 16 Apr 2025 07:50:00 GMT, Timofei Pushkin <tpushkin at openjdk.org> wrote:

>> src/java.base/share/classes/jdk/internal/misc/CDS.java line 390:
>> 
>>> 388:             @Override
>>> 389:             public byte[] readClassFile(String className) throws IOException {
>>> 390:                 final var subPath = className.replace('.', File.separatorChar).concat(".class");
>> 
>> Should File.separatorChar be ‘/‘ ? (just like at line 369)
>
> No, this is an intentional difference.
> 
> Here the string is then passed to `Path.of(...)` so it should definitely be `File.separatorChar` because this is what `Path.of(...)` expects.
> 
> Regarding line 369, the string is then passed to `JarFile.getEntry(String name)` — I wasn't able to find the description of the format of the `name` parameter so I followed the way `URLClassLoader` does it, it uses `/` for loading from a JAR (and `File.separatorChar` for loading from a directory). This seems logical since JAR format is platform-independent.

Thanks for the explanation.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/24223#discussion_r2048268934


More information about the hotspot-runtime-dev mailing list