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.
While inspecting whitelist classes violations http://wiki.netbeans.org/FitnessViaWhiteAndBlackList I have found that non-trivial amount of CND debugger classes is loaded into VM in spite there is no CND project, no CND file, no CND editor. Example of loaded classes: org.netbeans.modules.cnd.debug.DebugUtils org.netbeans.modules.cnd.debugger.common.EditorContext org.netbeans.modules.cnd.debugger.common.EditorContextBridge org.netbeans.modules.cnd.debugger.common.EditorContextImpl org.netbeans.modules.cnd.debugger.common.breakpoints.ToggleBreakpointActionProvider Please change your code to not initialize any of your classes until the user really starts to manipulate with C/C++ files.
The classes are initialized from debugger infrastructure: org.netbeans.modules.cnd.debugger.common.EditorContextBridge.getContext(EditorContextBridge.java:79) org.netbeans.modules.cnd.debugger.common.breakpoints.ToggleBreakpointActionProvider.<init>(ToggleBreakpointActionProvider.java:67) java.lang.reflect.Constructor.newInstance(Constructor.java:513) org.netbeans.spi.debugger.ContextAwareSupport.createInstance(ContextAwareSupport.java:134) org.netbeans.api.debugger.Lookup$MetaInf$MetaInfLookupList$LazyInstance.getEntry(Lookup.java:698) org.netbeans.api.debugger.Lookup$LookupList$LookupLazyEntry.get(Lookup.java:808) org.netbeans.api.debugger.LazyArrayList.get(LazyArrayList.java:158) org.netbeans.api.debugger.LazyArrayList$Itr.next(LazyArrayList.java:215) org.netbeans.api.debugger.ActionsManager.registerActionsProviders(ActionsManager.java:420) org.netbeans.api.debugger.ActionsManager.initActionImpls(ActionsManager.java:439) org.netbeans.api.debugger.ActionsManager.isEnabled(ActionsManager.java:253) org.netbeans.modules.debugger.ui.actions.DebuggerAction.isEnabled(DebuggerAction.java:121) org.netbeans.modules.debugger.ui.actions.DebuggerAction.<init>(DebuggerAction.java:76) org.netbeans.modules.debugger.ui.actions.DebuggerAction.createKillAction(DebuggerAction.java:161) I believe the infrastructure shall provide an enhanced way to register action providers, so they are not activated until their file type (in this case C/C++) is really selected. To verify the problem is fixed. hg backout http://hg.netbeans.org/ergonomics/rev/562be278d089 and run the whitelist test as described at http://wiki.netbeans.org/FitnessViaWhiteAndBlackList
The same problem applies to JPDA debugger. Excluding its classes too: http://hg.netbeans.org/ergonomics/rev/3bd1b2edffbc
Created attachment 93876 [details] The simple API addition that is able to delay class loading. Implementing this simple API change we're able to delay loading of debugger actions until a file with the given MIME type is selected in the IDE.
This is a simple API addition, so it should go through review. But due to it's simplicity I think we could process it sooner if guys from CND and Yarda agree with this change... I'd just add @since to these methods and apichanges. I'm also going to write a test in the mean time...
IS0: How will attaching work? There's no files or mime types to be selected.
This is not about attaching. This is about toggle breakpoint action, or any other context-sensitive action that have sense only on files of some concrete MIME type(s).
Well, I'd like to see a bit more than just two methods. Implementation, changed usage and a test (at least adding few new classes to ide.kit/**/blacklist.txt). As far as the change goes, it is OK, just without the above, it is quite hard to guess how good the change is.
O.K. I'll attach that soon. Implementation is ready, working on test...
Created attachment 93930 [details] API change with the implementation and a test. Attaching the implementation and a test. The test uses a fake FileObject with pre-defined MIME type to simulate a selected file. The test passes and also Java's ToggleBreakpointActionProvider with the following annotation: @ActionsProvider.Registration(getActions={ "toggleBreakpoint" }, enabledOnMIMETypes={ "text/x-java" }) Behaves as expected - the instance is created after a file with java MIME type becomes active in the IDE.
Y01 Maybe revert the sentence: "A declarative mechanism that creates action provider instance after a file with specific MIME type becomes active." - "A declarative mechanism to delay creation of action provider instance until a file with specific MIME type becomes active." Y02 getActions() should be just actions(). Y03 enabledOnMIMETypes() is missing description of the behavior when the value is left to default (I expect that it instantiates the provider immediately, but it is better to mention that). Y04 Maybe rename enabledOnMIMETypes() to activateFor(). I am not sure myself, but some English speaking reviewer could suggest some nice name... Y05 Also consider adding few entries to ide.kit/**/blacklist.txt and removing some from ide.kit/**/whitelist*.txt
Y01 Yes, it's more readable, thanks. Y02 O.K. Y03 Description added: /** * Provide a list of MIME types that are compared to the MIME type of * a file currently active in the IDE and when matched, this provider * is activated (an instance of the registered class is created). * By default, the provider instance is created immediately. * This method can be used to delay the instantiation of the * implementation class for performance reasons. * @return The list of MIME types * @since 1.23 */ Y04 activateFor() sounds more general, which might complicate things is we need properties other than the MIME type to check the enabled state in the future. Y05 org.netbeans.modules.cnd.debug.DebugUtils has nothing to do with this issue. I've made changes to all debuggers and modified the blacklist and whitelist.
Created attachment 93942 [details] Use of MIME type - specific actions added into all debuggers.
Thanks for the review, I'll push the change tomorrow.
Fixed in changeset: 159884:4852f5f4189c http://hg.netbeans.org/main/rev/4852f5f4189c
Integrated into 'main-golden', will be available in build *201002120200* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main/rev/4852f5f4189c User: mentlicher@netbeans.org Log: #177561 - Add a mechanism that allows to activate action provider only after files with specific MIME types become active. Implemented to all context-sensitive debugger actions for performance reasons.
Integrated into 'main-golden' Changeset: http://hg.netbeans.org/main-golden/rev/ User: Log: