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 201871 - UseNbBundleMessages exports ASTs outside of UserAction/Modification tasks.
Summary: UseNbBundleMessages exports ASTs outside of UserAction/Modification tasks.
Status: RESOLVED FIXED
Alias: None
Product: apisupport
Classification: Unclassified
Component: Refactoring (show other bugs)
Version: 7.1
Hardware: All All
: P2 normal (vote)
Assignee: Jesse Glick
URL:
Keywords:
Depends on: 207577
Blocks:
  Show dependency tree
 
Reported: 2011-09-09 08:48 UTC by Dusan Balek
Modified: 2012-04-14 09:43 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Proposed patch (22.30 KB, patch)
2011-09-09 08:48 UTC, Dusan Balek
Details | Diff
A minimal up-to-date patch. (1.76 KB, patch)
2012-04-11 13:36 UTC, Jan Lahoda
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dusan Balek 2011-09-09 08:48:34 UTC
Created attachment 110560 [details]
Proposed patch

See the 'MethodInvocationTree mit' - its value is calculated inside UseNbBundleMessages.run() running within a JavaSource's Task and it is used later in Fix.implement() method running within antoher ModificationTask. If there is something that invalidates the JavaSource between the hint's computation and invocation, the JavaSource gets reparsed ant the hint stops working (the original tree is no more present in the new JavaSource' AST after reparse). When working with the NB Java infrastructure, please keep in mind that all javac internal data structures (like trees, elements, types, etc.) are valid only within tasks that created them and should not be exported outside.
Comment 1 Jesse Glick 2011-09-09 16:51:27 UTC
I knew about that rule but did not realize the hint was violating it. Is there some way the infrastructure can detect such cases and issue a warning to the log? Perhaps by associating a long taskID with every Tree and refusing to work with a Tree coming from another task?

Also I am not sure under what conditions the source would be invalidated while you have an Alt-ENTER popup open - is there a known way to reproduce?
Comment 2 Dusan Balek 2011-09-13 09:15:30 UTC
The JavaSource is invalidated by the new OrganizeImports hint which calls ModificationResult.runModificationTask(...).
Comment 3 Jan Lahoda 2012-04-11 13:36:59 UTC
Created attachment 118131 [details]
A minimal up-to-date patch.
Comment 4 Jan Lahoda 2012-04-11 13:37:44 UTC
Effectively prevents possibility of using this hint in I&T, as it will lead into OOME eventually.
Comment 5 Jesse Glick 2012-04-12 02:18:01 UTC
Thanks for patch! core-main #2579a2b860a8
Comment 6 Quality Engineering 2012-04-13 09:49:27 UTC
Integrated into 'main-golden', will be available in build *201204130400* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/2579a2b860a8
User: Jan Lahoda <jlahoda@netbeans.org>
Log: #201871: UseNbBundleMessages exports ASTs outside of UserAction/Modification tasks.
Comment 7 Quality Engineering 2012-04-14 09:43:21 UTC
Integrated into 'main-golden', will be available in build *201204140400* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/84a1eb72a917
User: Jesse Glick <jglick@netbeans.org>
Log: Making #201871 fix clearer by separating fix into static nested class.