RFR: 8368030: Make package bundlers stateless
Alexander Matveev
almatvee at openjdk.org
Thu Sep 25 19:14:31 UTC 2025
On Thu, 25 Sep 2025 15:45:12 GMT, Alexey Semenyuk <asemenyuk at openjdk.org> wrote:
>> src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxDebPackager.java line 82:
>>
>>> 80: } catch (IOException ex) {
>>> 81: // Try the default path if differ
>>> 82: if (!realPath.toString().equals(file.toString())) {
>>
>> Why converting to `String`? `realPath` and `file` are both `Path`. `Path` has `equals` method.
>
> This code is copied from [LinuxDebBundler.java#L108](https://github.com/openjdk/jdk/blame/569e78080b3c25c95d85e9e194626f95f86b9b10/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxDebBundler.java#L108).
>
> `Path.equals()` will always return `true` as two Path objects reference the same file. The test must compare path strings, not that two Path objects reference the same file (which they do). That is why `String.equals()` is used.
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.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27377#discussion_r2380087187
More information about the core-libs-dev
mailing list