RFR: 8368030: Make package bundlers stateless
Alexander Matveev
almatvee at openjdk.org
Thu Sep 25 19:39:01 UTC 2025
On Thu, 25 Sep 2025 19:17:35 GMT, Alexey Semenyuk <asemenyuk at openjdk.org> wrote:
>> According to docs `Path.equals()` does not follow symbolic link, unless I miss read something. `isSameFile()` will return true if two paths reference the same file.
>
> A quote from https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/nio/file/Path.html#equals(java.lang.Object):
>
>> Where required, the [isSameFile](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/nio/file/Files.html#isSameFile(java.nio.file.Path,java.nio.file.Path)) method may be used to check if two paths locate the same file.
>
> In this specific case, two Path objects locate the same file; there is no point in comparing them. However, there is a need to compare their path strings, i.e, locators.
So, `realPath` and `file` locate the same file, but `file` can be symbolic link like `/usr/lib/symlinkToFile` and `realPath` will be `/usr/lib/File`. Assuming `/usr/lib/symlinkToFile` points to `/usr/lib/File`.
https://github.com/openjdk/jdk/blob/master/src/java.base/unix/classes/sun/nio/fs/UnixPath.java#L797
Based on implementation `equals()` should do the same as string comparison.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27377#discussion_r2380139714
More information about the core-libs-dev
mailing list