Bug 177561 - Don't initialize CND debugger until C/C++ file is selected
Don't initialize CND debugger until C/C++ file is selected
Status: RESOLVED FIXED
Product: debugger
Classification: Unclassified
Component: Code
6.x
All All
: P2 (vote)
: 6.x
Assigned To: Martin Entlicher
issues@debugger
perf-whitelist
: API, API_REVIEW_FAST, PERFORMANCE
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2009-11-25 01:36 UTC by Jaroslav Tulach
Modified: 2011-06-07 06:34 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
:


Attachments
The simple API addition that is able to delay class loading. (1.20 KB, patch)
2010-02-04 10:55 UTC, Martin Entlicher
Details | Diff
API change with the implementation and a test. (37.16 KB, patch)
2010-02-06 08:31 UTC, Martin Entlicher
Details | Diff
Use of MIME type - specific actions added into all debuggers. (58.19 KB, patch)
2010-02-07 09:22 UTC, Martin Entlicher
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jaroslav Tulach 2009-11-25 01:36:01 UTC
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.
Comment 1 Jaroslav Tulach 2009-11-25 01:41:42 UTC
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
Comment 2 Jaroslav Tulach 2009-11-25 01:47:22 UTC
The same problem applies to JPDA debugger. Excluding its classes too:
http://hg.netbeans.org/ergonomics/rev/3bd1b2edffbc
Comment 3 Martin Entlicher 2010-02-04 10:55:37 UTC
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.
Comment 4 Martin Entlicher 2010-02-04 11:02:24 UTC
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...
Comment 5 ivan 2010-02-04 13:02:07 UTC
IS0: How will attaching work?
     There's no files or mime types to be selected.
Comment 6 Martin Entlicher 2010-02-04 13:35:09 UTC
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).
Comment 7 Jaroslav Tulach 2010-02-04 17:49:41 UTC
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.
Comment 8 Martin Entlicher 2010-02-05 02:33:29 UTC
O.K. I'll attach that soon. Implementation is ready, working on test...
Comment 9 Martin Entlicher 2010-02-06 08:31:02 UTC
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.
Comment 10 Jaroslav Tulach 2010-02-07 01:56:25 UTC
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
Comment 11 Martin Entlicher 2010-02-07 09:20:22 UTC
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.
Comment 12 Martin Entlicher 2010-02-07 09:22:43 UTC
Created attachment 93942 [details]
Use of MIME type - specific actions added into all debuggers.
Comment 13 Martin Entlicher 2010-02-10 15:48:31 UTC
Thanks for the review, I'll push the change tomorrow.
Comment 14 Martin Entlicher 2010-02-11 04:53:34 UTC
Fixed in changeset:   159884:4852f5f4189c
http://hg.netbeans.org/main/rev/4852f5f4189c
Comment 15 Quality Engineering 2010-02-11 21:23:48 UTC
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.
Comment 16 Quality Engineering 2011-06-07 06:34:20 UTC
Integrated into 'main-golden'
Changeset: http://hg.netbeans.org/main-golden/rev/
User: 
Log:


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo