RFR: 8305072: Win32ShellFolder2.compareTo is inconsistent

Alexey Ivanov aivanov at openjdk.org
Tue Mar 5 17:07:02 UTC 2024


The implementation of `Win32ShellFolder2.compareTo` is inconsistent: there are cases where  
`a < b & b < c but a == c`  
which *violates its general contract*.

In particular, it happens for the personal folder (*Documents*) if it is listed *twice*: as a special and as a regular folder.

The evaluation performed by the submitter of the bug provided enough details to create a test, reproduce the problem and finally resolve it.

Without the fix, the regression test always fails:

a < b & b < c but a >= c
where
  a = C:\Users<user>\Documents(true)
  b = C:\Users<user>(false)
  c = C:\Users<user>\Documents(false)

as well as for the reverse case: `a > b & b > c`.

How it is possible to have the same folder in a list of files twice remains unknown. I believe it is another bug in JDK, however, no one has been able to reproduce it so far.

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

Commit messages:
 - 8305072: Fix Win32ShellFolder2.compareTo
 - 8305072: Add test case for Win32ShellFolder2.compareTo

Changes: https://git.openjdk.org/jdk/pull/18126/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=18126&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8305072
  Stats: 156 lines in 2 files changed: 154 ins; 0 del; 2 mod
  Patch: https://git.openjdk.org/jdk/pull/18126.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/18126/head:pull/18126

PR: https://git.openjdk.org/jdk/pull/18126


More information about the client-libs-dev mailing list