<Swing Dev> JDK 9 RFR of JDK-8054360: Refine generification of javax.swing
Anthony Petrov
anthony.petrov at oracle.com
Wed Aug 13 12:11:00 UTC 2014
Hi Joe,
The changes look good to me. +1.
--
best regards,
Anthony
On 8/13/2014 2:51 AM, Joe Darcy wrote:
> *ping*
>
> Any other comments here?
>
> Thanks,
>
> -Joe
>
> On 08/07/2014 07:20 PM, Joe Darcy wrote:
>> Hello,
>>
>> Please review my changes for
>>
>> JDK-8054360: Refine generification of javax.swing h
>> http://cr.openjdk.java.net/~darcy/8054360.3/
>>
>> Full patch below.
>>
>> This resolves many of the source incompatibility exemplars Jan Lahoda
>> found in a corpus of programs using swing.
>>
>> A few comments on the changes.
>>
>> It seems many existing implementations of the TreeNode interface have
>> a covariant override of the old raw
>>
>> Enumeration children();
>>
>> method which returns an enumeration of the specific TreeNode
>> implementation type. The revised generification of
>>
>> Enumeration<? extends TreeNode> children();
>>
>> allows those existing implementations to still compile. This is a
>> lower-impact way of allowing those types to still compile compared to
>> trying to add a type variable to TreeNode.
>>
>> After some expert generics advice from Dan Smith, I but together a
>> different generification of
>>
>> src/share/classes/javax/swing/table/DefaultTableModel.java
>>
>> which has better source compatibility. Quoting from the changes:
>>
>> 73 @SuppressWarnings("rawtypes")
>> 74 protected Vector<Vector> dataVector;
>> 75
>> 76 /** The <code>Vector</code> of column identifiers. */
>> 77 @SuppressWarnings("rawtypes")
>> 78 protected Vector columnIdentifiers;
>> 79 // Unfortunately, for greater source compatibility the
>> inner-most
>> 80 // Vector in the two fields above is being left raw. The
>> Vector is
>> 81 // read as well as written so using Vector<?> is not suitable
>> and
>> 82 // using Vector<Object> (without adding copying of input
>> Vectors),
>> 83 // would disallow existing code that used, say, a Vector<String>
>> 84 // as an input parameter.
>>
>> The setter methods used for these fields are changes to have
>> parameters of type Vector<?> and Vector<? extends Vector>, respectively.
>>
>> The type Vector<? extends Vector> is the most general type which
>> captures the implicit constraint of the dataVector field: it is a
>> Vector of other Vectors. (It would probably be possible to update
>> dataVector to the somewhat more general Vector<List>, but that would
>> require changes to the code in other methods of the class.)
>>
>> The changes in
>> src/share/classes/sun/tools/jconsole/inspector/TableSorter.java change
>> the code back to how it was before the swing generification changes
>> went in based on the changes to DefaultTableModel.
>>
>> Once the exact generification is settled, I'll file the internal ccc
>> paperwork.
>>
>> Early feedback on using this revised generification on swing code is
>> welcome!
>>
>> Thanks,
>>
>> -Joe
>>
>
More information about the swing-dev
mailing list