RFR: 8338626: CDS handling of JAR Class-Path attribute should allow / separator on Windows
Calvin Cheung
ccheung at openjdk.org
Tue Sep 10 20:58:12 UTC 2024
On Tue, 10 Sep 2024 20:50:58 GMT, Calvin Cheung <ccheung at openjdk.org> wrote:
>> Given these are required to be relative URLs [1] and given the path component of a URL only uses '/' as a separator [2], then it would seem the use of `os::file_separator` is wrong and it should just be hardcoded to '/' - and further it means the current code has never been correct on Windows. ??
>>
>> [1] https://docs.oracle.com/en/java/javase/21/docs/specs/jar/jar.html#class-path-attribute
>> [2] https://en.wikipedia.org/wiki/URL
>
> Consider `java -cp dir1/A.jar` ... where the manifiest of A.jar contains:
> `Class-Path: a.jar`
> The `dir_name` in the above corresponds to `dir1/A.jar`. The `strrchr` is trying to locate the separator between the directory and jar name. Later in the same function, it will combine the directory name (in this case `dir1`) with the names from each of the entry from the attribute and create a class path entry. In the example, it will create a class path entry of `dir1/a.jar`.
> Before the patch, on Windows, it only works with '\' (the default file separator). e.g.` java -cp dir1\A.jar` ... .
Also, the modified function is only called during CDS dump time for setting up the shared class paths for the app class loader.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/20924#discussion_r1752709527
More information about the hotspot-runtime-dev
mailing list