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.
CS.getCookie sometimes returns null even if the particular cookie exists. To reproduce this misbehaviour it is necessary to use CS.getCookie inside overridden Node.getCookie. This regression caused issue #48595. If you consider this as an intentional incompatible change it should be highlighted in the upgrade guide and in javadoc of Node and FilterNode since it is pretty hard to detect what's going wrong.
Removing REGRESSION as this behaviour is present in 3.6. So it is not regression anymore ;-)
This is a result of fix of issue 35856 - if the getCookieSet().getCookie is called from a NodeLookup.lookupItem, it knows that the real instance is not necessary and does not create it. I am affraid that there would be performance implications (like JavaEditor being created just by selecting a node in explorer) if I remove that behaviour. CCing performance guys to help us select the best solution. Here is the illegalstateexception that shows the execution really started from Lookup.lookupItem and the IllegalState is thrown because the CookieSet returned null. org.netbeans.modules.java.ui.nodes.BridgeUtils.throwIllegalState(BridgeUtils.java:164) org.netbeans.modules.java.ui.nodes.BridgeUtils.getElement(BridgeUtils.java:89) org.netbeans.modules.java.ui.nodes.BridgeUtils.getClassElement(BridgeUtils.java:52) org.netbeans.modules.java.ui.nodes.BridgeUtils.getElement(BridgeUtils.java:118) org.netbeans.modules.java.ui.nodes.BridgeUtils.getElement(BridgeUtils.java:62) org.netbeans.modules.java.ui.nodes.JavaSourceNodeFactory$CompatibleNode.getOldElement(JavaSourceNodeFactory.java:290) org.netbeans.modules.java.ui.nodes.JavaSourceNodeFactory$CompatibleNode.getCookie(JavaSourceNodeFactory.java:265) org.openide.nodes.NodeLookup.addCookie(NodeLookup.java:60) org.openide.nodes.NodeLookup.updateLookupAsCookiesAreChanged(NodeLookup.java:122) org.openide.nodes.NodeLookup.beforeLookup(NodeLookup.java:89) org.openide.util.lookup.AbstractLookup.lookupItem(AbstractLookup.java:306) org.openide.nodes.FilterNode$FilterLookup.lookupItem(FilterNode.java:1520) org.openide.util.actions.CookieAction.resolveSupported(CookieAction.java:137) org.openide.util.actions.CookieAction.doEnable(CookieAction.java:111) org.openide.util.actions.CookieAction.enable(CookieAction.java:101) org.openide.util.actions.NodeAction.isEnabled(NodeAction.java:121) org.openide.awt.Actions$MenuBridge.updateState(Actions.java:625) org.openide.awt.Actions$Bridge.propertyChange(Actions.java:350) java.beans.PropertyChangeSupport.firePropertyChange(Unknown Source) org.openide.util.SharedClassObject.firePropertyChange(SharedClassObject.java:389) org.openide.util.actions.NodeAction.maybeFireEnabledChange(NodeAction.java:258) org.openide.util.actions.NodeAction$NodesL.forget(NodeAction.java:381) org.openide.util.actions.NodeAction$NodesL.update(NodeAction.java:356) org.openide.util.actions.NodeAction$NodesL.resultChanged(NodeAction.java:348) org.openide.util.lookup.AbstractLookup.notifyListeners(AbstractLookup.java:405)
I guess that there is a simple workaround for this problem. If you really want the instance of JavaEditor to be created all the time, then do not ask for SourceCookie, but ask directly for JavaEditor, in such case the extra communication between CookieSet and NodeLookup will not take place as the cookie they are searching for will not match. But as I said performance regressions are likely to appear if you initialize JavaEditor all the time.