JDK-4809442 : Collections class should provide reverseOrder(Comparator)
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.util
  • Affected Version: 1.4.0
  • Priority: P5
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2003-01-28
  • Updated: 2017-05-16
  • Resolved: 2003-08-30
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availabitlity Release.

To download the current JDK release, click here.
Other
5.0 tigerFixed
Description

Name: jl125535			Date: 01/28/2003


FULL PRODUCT VERSION :
java version "1.4.0_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0_01-b03)
Java HotSpot(TM) Client VM (build 1.4.0_01-b03, mixed mode)

A DESCRIPTION OF THE PROBLEM :
The Collections class provides a method (reverseOrder() ) to return a
Comparator which compares in the opposite order of the natural ordering, but 
does not provide a comparator whose order is the reverse of the order of a 
given Comparator (reverseOrder(Comparator) )

REPRODUCIBILITY :
This bug can be reproduced always.

CUSTOMER WORKAROUND :
Implement own Comparator to perform this functionality.
This is trivial, but that doesn't mean it can't be in the
standard library--For example, the unmodifiable* and
synchronized* factories of the Collections class are also
trivial to implement.
(While you're at it, use a WeakHashMap to map from
Comparators to their reverse orders to avoid duplicate
objects. Not that you wouldn't have done so anyways, of
course.)
(Review ID: 158662) 
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: tiger FIXED IN: tiger INTEGRATED IN: tiger tiger-b18
2004-06-14

EVALUATION A reasonable request, especially as it's easy to get this wrong--it's not sufficient merely to negate the return value, as -Integer.MIN_VALUE is still negative. ###@###.### 2003-01-29
2003-01-29