Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8311264

JavaDoc index comparator is not transitive



    • Bug
    • Resolution: Fixed
    • P3
    • 22
    • 17, 18, 19, 20, 21
    • tools
    • b06
    • generic
    • generic



        The comparator used to sort items for the JavaDoc index pages does not guarantee transitivity.

        The index item comparator is a composite comparator which uses different sub-comparators for specific pairs of items being compared. The problem is that the element sub-comparator uses the qualified or simple element name as comparison key, while the sub-comparators that compare search tags or search tags to elements use the item label as key.

        For example, consider the following index items:

         - class "Date"
         - method "date()"
         - search tag "Date/Time"

        The element comparator uses the simple element name for methods and classes, thus compares "date" to "Date" when comparing the method to the class. Because of collation rules it determines that "date" < "Date".

        The label comparator uses the item label when comparing a search tag to an element, therefore it compares "date()" to "Date/Time" when comparing the method to the search tag, and "Date" to "Date/Time" when comparing the search tag to the class. Because of collation rules, it determines that "date()" > "Date/Time" and "Date/Time" > "Date". By the rule of transitivity, this implies that "date()" > "Date", which is the opposite of what the element comparator returned in direct comparison.

        This bug was triggered by JDK-8286470 adding a lot of section items to the index page, one of which was the "Date/Time" search tag described in the example above. The attached screenshot shows the effect on the `D` index page (the `date(...)` methods should be listed before the `Date` and `DATE` entries, right after `dataVector`).


          Issue Links



                hannesw Hannes Wallnoefer
                hannesw Hannes Wallnoefer
                0 Vote for this issue
                3 Start watching this issue