Skip to content

fix(spawn-jdk): make JDK.compareTo consistent with equals#52

Merged
deer merged 1 commit into
mainfrom
jdk_compareTo
Jul 16, 2026
Merged

fix(spawn-jdk): make JDK.compareTo consistent with equals#52
deer merged 1 commit into
mainfrom
jdk_compareTo

Conversation

@deer

@deer deer commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

JDK.compareTo(JDK) previously ordered instances solely by version(), but equals() also considers operatingSystem, architecture, and home. Two JDKs with the same version but different target platforms therefore compared as equal even though they weren't, which meant storing them in a SortedSet or TreeMap (e.g. a TreeSet<JDK>) would silently drop all but one entry.

The fix introduces a static ORDER comparator on JDK that chains version(), then operatingSystem(), architecture(), and finally home().path() as tie-breakers, and compareTo now delegates to it.

@deer deer merged commit a63eb94 into main Jul 16, 2026
1 check passed
@deer deer deleted the jdk_compareTo branch July 16, 2026 07:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant