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

Artem Ananiev artem.ananiev at oracle.com
Wed Aug 14 05:18:49 PDT 2013

Looks fine to me.



On 8/14/2013 3:17 PM, Petr Pchelko wrote:
> Hello, AWT Team.
> Please review the fix for the following issue:
> http://bugs.sun.com/view_bug.do?bug_id=7173464
> The fix is available at:
> http://cr.openjdk.java.net/~pchelko/7173464/webrev.00/
> 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