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.
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.
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?
The JavaSource is invalidated by the new OrganizeImports hint which calls ModificationResult.runModificationTask(...).
Created attachment 118131 [details] A minimal up-to-date patch.
Effectively prevents possibility of using this hint in I&T, as it will lead into OOME eventually.
Thanks for patch! core-main #2579a2b860a8
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.
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.