<AWT Dev> [8] Review Request: JDK-7173464 Clipboard.getAvailableDataFlavors: Comparison method violates contract

Petr Pchelko petr.pchelko at oracle.com
Wed Aug 14 04:17:56 PDT 2013

Hello, AWT Team.

Please review the fix for the following issue:
The fix is available at:

The problem:
DataTransfer.DataFlavorComparator sometimes returns 0 for non-equal DataFlavors. the reason is that some flavors are not comparable: for example Image and HTML. Before the fix handles to native flavor representations were used to compare incomparable flavors. this is bad for many reasons:
1. Exposing the existence of native handles to public methods
2. The order might change from run to run
3. For some DataFlavorComparator constructors native handles were not provided.

The solution:
The spec of the comparator was changed. Now it compares string representations of flavors, so now it's impossible that comparator returns 0 for non-equal flavors. 
The use of natives was removed. The class is a part of sun.awt package, there are not regression or JCK tests for this, so the spec could be safely changed. 
It's unlikely to have any regressions, because it really does not matter how to compare incomparable flavors.

With best regards. Petr.

More information about the awt-dev mailing list