<Swing Dev> [11][JDK-6303622]Use generic in Swing components like JComboBox

Krishna Addepalli krishna.addepalli at oracle.com
Tue Jan 30 13:51:11 UTC 2018


Hi Kevin,

 

Thanks for your review.

 

I have filed a CSR here: https://bugs.openjdk.java.net/browse/JDK-8196396

 

Source compatibility wise, the changes will produce warnings only in some cases. For example, with the below code snippet, there would be no warnings:

JComboBox cb = new JComboBox(new String[]{"one", "two", "three"});

String c = (String)cb.getSelectedItem();

 

Whereas the below code snippet would generate "redundant cast" warning on compilation.

JComboBox<String> cb = new JComboBox<>(new String[]{"one", "two", "three"});

String c = (String)cb.getSelectedItem();

 

Binary compatibility wise, I have checked that code that was compiled in jdk10 ran without any problems in jdk11. And also, behavior wise, there are no changes. 

 

Thanks,

Krishna

From: Kevin Rushforth 
Sent: Thursday, January 25, 2018 9:46 PM
To: Krishna Addepalli <krishna.addepalli at oracle.com>
Cc: swing-dev at openjdk.java.net
Subject: Re: <Swing Dev> [11][JDK-6303622]Use generic in Swing components like JComboBox

 

I presume you plan to file a CSR? Have you verified that this change preserves both binary and source code compatibility?

-- Kevin


Krishna Addepalli wrote: 

Hi All,

 

Please review a fix for the Enhancement:

 

JDK-6303622: https://bugs.openjdk.java.net/browse/JDK-6303622

Webrev: HYPERLINK "http://cr.openjdk.java.net/%7Ekaddepalli/6303622/webrev00/"http://cr.openjdk.java.net/~kaddepalli/6303622/webrev00/

 

The enhancement requests to provide the generic return type for getSelectedItem() to avoid ugly casts for the developers using the api. Have done changes accordingly for JComboBox and JList, and all supporting classes.

 

Thanks,

Krishna
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/swing-dev/attachments/20180130/6434a981/attachment.html>


More information about the swing-dev mailing list