RFR: 8338626: CDS handling of JAR Class-Path attribute should allow / separator on Windows

David Holmes dholmes at openjdk.org
Tue Sep 10 07:27:10 UTC 2024


On Tue, 10 Sep 2024 06:17:17 GMT, Alan Bateman <alanb at openjdk.org> wrote:

>> On Windows, we can use '/' as the file separator in the classpath but not in the `Class-Path:` attribute.
>> This patch is to enable the use of '/' as the file separator in the `Class-Path:`attribute on Windows.
>> 
>> Passed tiers 1 - 3 testing.
>
> src/hotspot/share/classfile/classLoaderExt.cpp line 221:
> 
>> 219:       dir_tail = strrchr(dir_name, '/');
>> 220:     }
>> 221: #endif
> 
> The value of the Class-Path attribute is a sequence of relative URLs, not file paths, so I wouldn't expect to see any usage of os::file_separator() here, even on Unix systems. Some further work may be needed here to align with how the Class-Path attribute is treated by the application class loader.

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

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

PR Review Comment: https://git.openjdk.org/jdk/pull/20924#discussion_r1751404931


More information about the hotspot-runtime-dev mailing list