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 177561 - Don't initialize CND debugger until C/C++ file is selected
Summary: Don't initialize CND debugger until C/C++ file is selected
Alias: None
Product: debugger
Classification: Unclassified
Component: Code (show other bugs)
Version: 6.x
Hardware: All All
: P2 normal (vote)
Assignee: Martin Entlicher
Depends on:
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
Exception Reporter:

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
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:


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:


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
and run the whitelist test as described at
Comment 2 Jaroslav Tulach 2009-11-25 01:47:22 UTC
The same problem applies to JPDA debugger. Excluding its classes too:
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.

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
Comment 15 Quality Engineering 2010-02-11 21:23:48 UTC
Integrated into 'main-golden', will be available in build *201002120200* on (upload may still be in progress)
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'