Bug 76146 - NPE using quickfix in Aspect opened with java editor

Bugzilla Bug 76146
|  | NPE using quickfix in Aspect opened with java editor

Bug List: First Last (This bug is not in your list) Show list Query page Enter new bug

Bug#: | 76146 |  | Platform: |  |  | Reporter: | hawkinsh@uk.ibm.com (Helen Hawkins)
Product: |  |  | OS: |  |  | Add CC: |
Component: |  |  | Version: |  |  | CC: |
Status: | NEW |  | Priority: |  |
Resolution: |  |  | Severity: |  |
Assigned To: | mchapman@uk.ibm.com (Matt Chapman) |  | Target Milestone: |  |
URL: |
Summary: |
Keywords: |

Attachment | Type | Modified | Status | Actions
--- | --- | --- | --- | ---
Create a New Attachment (proposed patch, testcase, etc.) | View All

Bug 76146 depends on: |  |  | Show dependency tree
Bug 76146 blocks: |  |

Additional Comments:
Leave as NEW
Accept bug (change status to ASSIGNED)
Resolve bug, changing resolution to
Resolve bug, mark it as duplicate of bug #
Reassign bug to
Reassign bug to owner of selected component

View Bug Activity | Format For Printing

Description: | Opened: 2004-10-13 04:51

    To recreate:

    - Check out the QuickFix project from ajdt.test project
    java.lang.NullPointerException- Open TestAspect.java in the Java Editor (right click > open with > Java
    Editor)
    - Click on the lightbulb with the error marker (the same line as File f = new
    File("tmp");
    java.lang.NullPointerException- An Internal Error appear in the Error log with the following stack trace:

    java.lang.NullPointerException
    at
    org.eclipse.jdt.internal.ui.text.correction.UnresolvedElementsSubProcessor.getT
    ypeProposals(UnresolvedElementsSubProcessor.java:395)
    at org.eclipse.jdt.internal.ui.text.correction.QuickFixProcessor.process
    (QuickFixProcessor.java:270)
    at org.eclipse.jdt.internal.ui.text.correction.QuickFixProcessor.getCorrections
    (QuickFixProcessor.java:202)
    at
    org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionProcessor.collectCorr
    ections(JavaCorrectionProcessor.java:240)
    at
    org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionProcessor.processAnno
    tations(JavaCorrectionProcessor.java:208)
    at
    org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionProcessor.computeComp
    letionProposals(JavaCorrectionProcessor.java:177)
    at
    org.eclipse.jface.text.contentassist.ContentAssistant.computeCompletionProposal
    s(ContentAssistant.java:1472)
    at
    org.eclipse.jface.text.contentassist.CompletionProposalPopup.computeProposals
    (CompletionProposalPopup.java:242)
    at org.eclipse.jface.text.contentassist.CompletionProposalPopup.access$7
    (CompletionProposalPopup.java:238)
    at org.eclipse.jface.text.contentassist.CompletionProposalPopup$1.run
    (CompletionProposalPopup.java:197)
    at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:69)
    at org.eclipse.jface.text.contentassist.CompletionProposalPopup.showProposals
    (CompletionProposalPopup.java:192)
    at
    org.eclipse.jface.text.contentassist.ContentAssistant.showPossibleCompletions
    (ContentAssistant.java:1320)
    at
    org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionAssistant.showPossibl
    eCompletions(JavaCorrectionAssistant.java:159)
    at
    org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor$AdaptedSourceViewe
    r.doOperation(CompilationUnitEditor.java:184)
    at org.eclipse.jdt.internal.ui.javaeditor.JavaSelectAnnotationRulerAction.run
    (JavaSelectAnnotationRulerAction.java:78)
    at org.eclipse.ui.texteditor.AbstractRulerActionDelegate.run
    (AbstractRulerActionDelegate.java:99)
    at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:276)
    at org.eclipse.ui.internal.PluginAction.run(PluginAction.java:238)
    at org.eclipse.ui.texteditor.AbstractTextEditor$11.triggerAction
    (AbstractTextEditor.java:2110)
    at org.eclipse.ui.texteditor.AbstractTextEditor$11.mouseUp
    (AbstractTextEditor.java:2117)
    at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:136)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:796)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2772)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2431)
    at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1377)
    at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1348)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:254)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:141)
    at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:96)
    at org.eclipse.core.internal.runtime.PlatformActivator$1.run
    (PlatformActivator.java:335)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:273)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:129)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke
    (NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke
    (DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:324)
    at org.eclipse.core.launcher.Main.basicRun(Main.java:183)
    at org.eclipse.core.launcher.Main.run(Main.java:644)
    at org.eclipse.core.launcher.Main.main(Main.java:628)

    Looking at the jdt code in UnresolvedElementsSubProcessor.java, at line 395,
    the parent field is null:

    	ASTNode parent= selectedNode.getParent();
    	while (parent.getLength() == selectedNode.getLength()) { // line 395
    			parent= parent.getParent();
    	}

    java.lang.NullPointerException There just needs to be a null check as there is above:

    	ASTNode selectedNode= problem.getCoveringNode(context.getASTRoot());
    	if (selectedNode == null) {
    		return;
    	}
    	int kind= SimilarElementsRequestor.ALL_TYPES;

    	ASTNode parent= selectedNode.getParent();
    	while (parent.getLength() == selectedNode.getLength()) {
    		parent= parent.getParent();
    	}

    should become:

    	ASTNode selectedNode= problem.getCoveringNode(context.getASTRoot());
    	if (selectedNode == null) {
    		return;
    	}
    	int kind= SimilarElementsRequestor.ALL_TYPES;

    	ASTNode parent= selectedNode.getParent();
    	if (parent == null) {
    		return;
    	}
    	while (parent.getLength() == selectedNode.getLength()) {
    		parent= parent.getParent();
    	}

    This needs to be raised as a jdt bug, since we don't pass through any ajdt
    code in order to get here.

    Raising this bug against ajdt is just for tracking.

    (note this happens on 1.1.12, but also on the latest AJDT dev build).

Bug List: First Last (This bug is not in your list) Show list Query page Enter new bug

This is Bugzilla: the Mozilla bug system. For more information about what Bugzilla is and what it can do, see bugzilla.org.
Actions: | New | Query | bug # | Reports |  | New Account | Log In