This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 227943 - warning: [rawtypes] found raw type: JList
Summary: warning: [rawtypes] found raw type: JList
Status: RESOLVED FIXED
Alias: None
Product: guibuilder
Classification: Unclassified
Component: Code (show other bugs)
Version: 7.3
Hardware: All All
: P3 normal with 1 vote (vote)
Assignee: issues@guibuilder
URL:
Keywords:
: 250586 250588 255189 (view as bug list)
Depends on:
Blocks:
 
Reported: 2013-03-26 11:23 UTC by Tomas Mysik
Modified: 2015-09-16 01:25 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tomas Mysik 2013-03-26 11:23:54 UTC
Now, when we switched to Java 7, javac complains while building Matisse classes:

warning: [rawtypes] found raw type: JList

BTW I prefer DEFECT since there is no way to avoid such warnings (I mean for Matisse code) in the log - or is it?

Thanks.

Product Version: NetBeans IDE 7.3 (Build 201302132200)
Java: 1.7.0_17; Java HotSpot(TM) 64-Bit Server VM 23.7-b01
Runtime: Java(TM) SE Runtime Environment 1.7.0_17-b02
System: Linux version 3.5.0-26-generic running on amd64; UTF-8; cs_CZ (nb)
Comment 1 Tomas Pavek 2013-03-27 16:20:04 UTC
A way to fix this is to open the GUI form, select JList component, go to Code properties and set "Type Parameters" property to <Object>.

A fix in GUI builder could be to set the property automatically when adding a new JList component (on JDK 7+). I don't think the GUI builder should try to do that for existing forms. BTW there are typically other warnings from user code when using the JList (like from setModel or setCellRenderer) which need to be fixed manually as well.

Or adjust the level of compile warnings produced by the NetBeans build. E.g. in a standard Java SE project I don't see the warnings. It seems to be a specialty of the NBM projects.
Comment 2 Tomas Mysik 2013-03-27 16:32:01 UTC
Tome, thanks a lot for perfect information, as always.
Comment 3 Tomas Pavek 2015-09-10 16:23:21 UTC
To fix this, the GUI builder should automatically set <Object> or <String> as the type parameter for JComboBox and JList newly added to the form and then also generate the diamond <> in constructor call a in code that creates the models. So e.g.:

private javax.swing.JComboBox<String> jComboBox1;

jComboBox1 = new javax.swing.JComboBox<>();

jComboBox2.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));


For existing (old) forms with no type parameter set we should probably not generate the diamonds in component and model constructors (though the code compiles either way). For old forms with no type parameter we probably cannot detect it reliably - the user will have to set it manually to get rid of compile warnings.
Comment 4 Tomas Pavek 2015-09-10 16:27:04 UTC
*** Bug 250588 has been marked as a duplicate of this bug. ***
Comment 5 Tomas Pavek 2015-09-10 16:27:58 UTC
Also related: bug 223998.
Comment 6 Tomas Pavek 2015-09-10 16:33:15 UTC
*** Bug 255189 has been marked as a duplicate of this bug. ***
Comment 7 Tomas Pavek 2015-09-11 13:14:12 UTC
*** Bug 250586 has been marked as a duplicate of this bug. ***
Comment 8 Tomas Pavek 2015-09-15 12:36:01 UTC
Made a fix so that newly added JList and JComboBox have automatically <Object> type parameter set and <> is correctly generated for constructor and model.

To fix old forms containing lists/combo boxes without type parameter it should be enough to set it manually to Object (in Code tab, Type Parameters property) and that should get rid of all compile warnings.

For existing forms that have the type parameters set by user, to get the <> generated (e.g. instead of current superfluous new javax.swing.JComboBox<String>()), it should be enough to do whatever change in an opened GUI form to trigger code regeneration.

http://hg.netbeans.org/jet-main/rev/b9a55880ddde
Comment 9 Quality Engineering 2015-09-16 01:25:54 UTC
Integrated into 'main-silver', will be available in build *201509160002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/b9a55880ddde
User: Tomas Pavek <tpavek@netbeans.org>
Log: #227943: automatically set type parameter for JList and JComboBox, use diamond in generated code where it should be