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

Allow UUID proper comparison

XMLWordPrintable

    • generic
    • generic

      A DESCRIPTION OF THE PROBLEM :
      As reported here https://bugs.openjdk.org/browse/JDK-7025832 the compareTo in UUID does not conform to the UUID standard.

      Is there any way that this can be addressed?

      Tried to implement the comparator, but mostSigBits is private, so it's not possible to write client code like:

      ```
              int mostSigBits = Long.compareUnsigned(this.mostSigBits, val.mostSigBits);
              return mostSigBits != 0 ? mostSigBits : Long.compareUnsigned(this.leastSigBits, val.leastSigBits);
      ```

      The only option is to serialize to String and compare, which is obviously not good from a performance point of view.

      Would it be possible for the UUID to expose a standard compliant method, even if it is not the comparator interface? Or a JDK flag that would allow using the right comparator?


            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: