<Swing Dev> JDK 9 RFR of JDK-8055254: Address source incompatability of JSlider generification

Sergey Bylokhov Sergey.Bylokhov at oracle.com
Mon Aug 18 10:27:17 UTC 2014


Hi, Joe.
The fix looks good.

On 18.08.2014 2:53, Joe Darcy wrote:
> Hello,
>
> As noted by Sergey, the recently pushed changes for
>
>     JDK-8054360: Refine generification of javax.swing
>
> cause one of the files in SwingSet2 to not build, breaking the 
> combined open + closed JDK build.
>
> To remedy this situation, at least in the short term, please review 
> the proposed changes for
>
>      JDK-8055254: Address source incompatability of JSlider 
> generification
>     http://cr.openjdk.java.net/~darcy/8055254.0/
>
> In brief, the label table information in JSlider is reverted to be a 
> raw Dictionary rather than
>
>     * A Dictionary<Integer, ? extends JComponent> as under 8054360
>     * A Dictionary<Integer, JComponent> as under JDK-8043550 (earlier 
> swing generification)
>
> (The usage patterns of the label table from the get/set methods seems 
> to include modifying the returned table, which is problematic if 
> wildcards are used.)
>
> For a bit more information, here is a diff of the non-javadoc changes 
> between the pre JDK-8043550 state of the slider files and the proposed 
> changes:
>
> diff JSlider.java ../jdk/src/share/classes/javax/swing/JSlider.java
> 140a141
> >     @SuppressWarnings("rawtypes")
> 142c143,145
> <
> ---
> >     // For better source compatibility, the labelTable field and
> >     // associated getter and setter methods are being left as raw
> >     // types.
> 772c779
> <         Enumeration elements = labelTable.elements();
> ---
> >         Enumeration<?> elements = labelTable.elements();
> 795a803
> >     @SuppressWarnings("rawtypes")
> 828a837
> >     @SuppressWarnings("rawtypes")
> 850a860
> >         @SuppressWarnings("rawtypes")
> 856c866
> <         Enumeration labels = labelTable.keys();
> ---
> >         Enumeration<?> labels = labelTable.keys();
> 864a875
> >         @SuppressWarnings("rawtypes")
> 867c878
> <             Enumeration labels = labelTable.elements();
> ---
> >             Enumeration<?> labels = labelTable.elements();
> 897c908
> <     public Hashtable createStandardLabels( int increment ) {
> ---
> >     public Hashtable<Integer, JComponent> createStandardLabels( int 
> increment ) {
> 925c936
> <     public Hashtable createStandardLabels( int increment, int start ) {
> ---
> >     public Hashtable<Integer, JComponent> createStandardLabels( int 
> increment, int start ) {
> 934c945
> <         class SmartHashtable extends Hashtable<Object, Object> 
> implements PropertyChangeListener {
> ---
> >         class SmartHashtable extends Hashtable<Integer, JComponent> 
> implements PropertyChangeListener {
> 981,982c992,993
> <                     Enumeration keys = getLabelTable().keys();
> <                     Hashtable<Object, Object> hashtable = new 
> Hashtable<Object, Object>();
> ---
> >                     Enumeration<?> keys = getLabelTable().keys();
> >                     Hashtable<Integer, JComponent> hashtable = new 
> Hashtable<>();
> 986,987c997,998
> <                         Object key = keys.nextElement();
> <                         Object value = labelTable.get(key);
> ---
> >                         Integer key = (Integer) keys.nextElement();
> >                         JComponent value = (JComponent) 
> labelTable.get(key);
> 999c1010
> <                         Object key = keys.nextElement();
> ---
> >                         Integer key = (Integer) keys.nextElement();
> 1015a1027
> >         @SuppressWarnings("rawtypes")
> 1524d1535
> <
>
> diff BasicSliderUI.java 
> ../jdk/src/share/classes/javax/swing/plaf/basic/BasicSliderUI.java
> 399a400
> >             @SuppressWarnings("rawtypes")
> 403c404
> <                 Enumeration elements = dictionary.elements();
> ---
> >                 Enumeration<?> elements = dictionary.elements();
> 755a762
> >         @SuppressWarnings("rawtypes")
> 759c766
> <             Enumeration keys = dictionary.keys();
> ---
> >             Enumeration<?> keys = dictionary.keys();
> 768a776
> >         @SuppressWarnings("rawtypes")
> 772c780
> <             Enumeration keys = dictionary.keys();
> ---
> >             Enumeration<?> keys = dictionary.keys();
> 844a853
> >         @SuppressWarnings("rawtypes")
> 851c860
> <         Enumeration keys = dictionary.keys();
> ---
> >         Enumeration<?> keys = dictionary.keys();
> 873a883
> >         @SuppressWarnings("rawtypes")
> 880c890
> <         Enumeration keys = dictionary.keys();
> ---
> >         Enumeration<?> keys = dictionary.keys();
> 1123a1142
> >         @SuppressWarnings("rawtypes")
> 1126c1145
> <             Enumeration keys = dictionary.keys();
> ---
> >             Enumeration<?> keys = dictionary.keys();
>
> diff SynthSliderUI.java 
> ../jdk/src/share/classes/javax/swing/plaf/synth/SynthSliderUI.java | more
> 2c2
> <  * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All 
> rights reserved.
> ---
> >  * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All 
> rights reserved.
> 394c394,395
> <
> ---
> >
> >                 @SuppressWarnings("rawtypes")
> 405c406
> <                     for (Enumeration keys = dictionary.keys();
> ---
> >                     for (Enumeration<?> keys = dictionary.keys();
>
> The raw and unchecked warnings are now enabled in the build of the JDK 
> so the changes for 8055254 must preserve that property, which is 
> largely done by suppressing some warnings and judicious use of some 
> wildcards on local variables.
>
> Thanks,
>
> -Joe


-- 
Best regards, Sergey.




More information about the swing-dev mailing list