Skip to content

Fix rare CCE in the interface selector UI of the new-java-class wizard#9050

Merged
mbien merged 1 commit intoapache:masterfrom
mbien:fix-cce-in-interface-filter
Dec 1, 2025
Merged

Fix rare CCE in the interface selector UI of the new-java-class wizard#9050
mbien merged 1 commit intoapache:masterfrom
mbien:fix-cce-in-interface-filter

Conversation

@mbien
Copy link
Copy Markdown
Member

@mbien mbien commented Nov 29, 2025

The code replaced a typed ListModel with a dummy model containing a single String which can sometimes cause a CCE in the interface selector filter.

The dummy model isn't really needed since the goto component does handle the "search in progress" state already, so I removed it.

Fixed more rawtype compiler warnings to avoid similar issues in future.

exception:

Details
java.lang.ClassCastException: class java.lang.String cannot be cast to class org.netbeans.spi.jumpto.type.TypeDescriptor (java.lang.String is in module java.base of loader 'bootstrap'; org.netbeans.spi.jumpto.type.TypeDescriptor is in unnamed module of loader org.netbeans.StandardModule$OneModuleClassLoader @20e1c8f2)
	at org.netbeans.modules.jumpto.type.GoToPanel$PatternListener.valueChanged(GoToPanel.java:554)
	at java.desktop/javax.swing.JList.fireSelectionValueChanged(JList.java:1831)
	at java.desktop/javax.swing.JList$ListSelectionHandler.valueChanged(JList.java:1845)
	at java.desktop/javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:231)
	at java.desktop/javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:206)
	at java.desktop/javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:258)
	at java.desktop/javax.swing.DefaultListSelectionModel.changeSelection(DefaultListSelectionModel.java:459)
	at java.desktop/javax.swing.DefaultListSelectionModel.changeSelection(DefaultListSelectionModel.java:469)
	at java.desktop/javax.swing.DefaultListSelectionModel.setSelectionInterval(DefaultListSelectionModel.java:513)
	at java.desktop/javax.swing.JList.setSelectedIndex(JList.java:2232)
	at org.netbeans.modules.jumpto.type.GoToPanel.setModel(GoToPanel.java:149)
	at org.netbeans.modules.jumpto.type.GoToPanel.revalidateModel(GoToPanel.java:163)
	at org.netbeans.modules.jumpto.type.GoToTypeAction.setListModel(GoToTypeAction.java:282)
	at org.netbeans.modules.jumpto.type.GoToPanel$PatternListener.update(GoToPanel.java:572)
	at org.netbeans.modules.jumpto.type.GoToPanel$PatternListener.update(GoToPanel.java:563)
	at org.netbeans.modules.jumpto.type.GoToPanel$PatternListener.insertUpdate(GoToPanel.java:533)
	at java.desktop/javax.swing.text.AbstractDocument.fireInsertUpdate(AbstractDocument.java:220)
...

reproduce:

open new java class wizard, and use the interfaces filter (browse button) often enough until the exception occurs.

regression since #8896

@mbien mbien added this to the NB29 milestone Nov 29, 2025
@mbien mbien added Editor ci:dev-build [ci] produce a dev-build zip artifact (7 days expiration, see link on workflow summary page) labels Nov 29, 2025
Comment on lines 501 to 505
final Models.MutableListModel baseModel = Models.mutable(
final Models.MutableListModel<TypeDescriptor> baseModel = Models.mutable(
ic,
currentSearch.resetFilter(),
null);
final ListModel model = typeFilter != null ?
FilteredListModel.create(baseModel, new FilterAdaptor(typeFilter), NbBundle.getMessage(GoToTypeAction.class, "LBL_Computing")) :
@SuppressWarnings("unchecked")
final ListModel<TypeDescriptor> model = typeFilter != null ?
FilteredListModel.create(baseModel, new FilterAdaptor(typeFilter), null) :
baseModel;
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was what passed a String into the model + replaced the typed model with it a few lines later. The initial value is now null since it wouldn't show up anyway.

@mbien mbien requested a review from lkishalmi November 30, 2025 04:49
Copy link
Copy Markdown
Contributor

@matthiasblaesing matthiasblaesing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks sane to me. You might want to consider generifying FilteredListModel. Only compile checked this, but it shows the idea: 3444f2d.

The code replaced a typed ListModel with a dummy model containing a
single String which can cause a CCE in the interface selector filter.

The dummy model isn't really needed since the goto component does
handle the "search in progress" state already, so I removed the default
value.

Fixed more rawtype compiler warnings to avoid similar issues in future.
@mbien
Copy link
Copy Markdown
Member Author

mbien commented Dec 1, 2025

had some of it in my stash already but wasn't sure if i should add it here. Will add it with a few more rawtype fixes in the related files.

@mbien mbien removed the ci:dev-build [ci] produce a dev-build zip artifact (7 days expiration, see link on workflow summary page) label Dec 1, 2025
@mbien mbien force-pushed the fix-cce-in-interface-filter branch from 3e45a18 to b2ad041 Compare December 1, 2025 11:52
@mbien mbien merged commit 0f6eb1e into apache:master Dec 1, 2025
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants