[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[equinox-dev] result of VersionHashMap.compare() depends on sort algorithm?
- From: "Sievers, Jan" <jan.sievers@xxxxxxx>
- Date: Wed, 10 Jul 2013 08:34:05 +0000
- Accept-language: en-US
- Delivered-to: firstname.lastname@example.org
- Thread-index: Ac59SDv+ueb2QmZiQ3GtKE7PK9ng4Q==
- Thread-topic: result of VersionHashMap.compare() depends on sort algorithm?
in the course of tycho bug
we found that that the result of sorting resolverExports in ResolverImpl  depends on the JDK Collections.sort() algorithm implementation.
It seems that for two VersionSuppliers which are equal according to all comparison attributes, the (arbitrary) order of vs1 and vs2 in compare(V vs1, V vs2) decides which one wins .
This would not matter as long as the two VersionSuppliers are really equal.
However if you are interested in whether the package is a system export , the directive equinox-ee matters.
Now if you have several suppliers of the same package (system-exported and not system-exported), the result of StateHelperImpl.isSystemExport() effectively depends on the JDK sort algorithm. (This is because GenericSpecificationImpl.getSupplier()  takes the first package in the (sorted) list if several are present)
Is the sort result depending on the JDK sort algorithm implementation in this case a bug or intended behaviour?
For the tycho bug, I have a tentative patch ; Can you comment if this is the correct way to fix it?