Bug 465156 - NPE in CompletionEngine.findLocalMethods (8737)
Summary: NPE in CompletionEngine.findLocalMethods (8737)
Status: CLOSED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.5   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords: needinfo
Depends on:
Blocks:
 
Reported: 2015-04-22 00:25 EDT by EPP Error Reports CLA
Modified: 2019-11-03 16:24 EST (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description EPP Error Reports CLA 2015-04-22 00:25:12 EDT
The following incident was reported via the automated error reporting:


    code:                   1
    plugin:                 org.eclipse.recommenders.subwords.rcp_2.1.13.v20150323-0859
    message:                Exception during code completion
    fingerprint:            258fe183
    exception class:        java.lang.NullPointerException
    exception message:      -
    number of children:     0
    
    java.lang.NullPointerException: null
    at org.eclipse.jdt.internal.codeassist.CompletionEngine.findLocalMethods(CompletionEngine.java:8737)
    at org.eclipse.jdt.internal.codeassist.CompletionEngine.findInterfacesMethods(CompletionEngine.java:8023)
    at org.eclipse.jdt.internal.codeassist.CompletionEngine.findMethods(CompletionEngine.java:10009)
    at org.eclipse.jdt.internal.codeassist.CompletionEngine.findVariablesAndMethods(CompletionEngine.java:11855)
    at org.eclipse.jdt.internal.codeassist.CompletionEngine.completionOnSingleNameReference(CompletionEngine.java:3295)
    at org.eclipse.jdt.internal.codeassist.CompletionEngine.complete(CompletionEngine.java:1713)
    at org.eclipse.jdt.internal.codeassist.CompletionEngine.complete(CompletionEngine.java:1939)
    at org.eclipse.jdt.internal.core.Openable.codeComplete(Openable.java:131)
    at org.eclipse.jdt.internal.core.CompilationUnit.codeComplete(CompilationUnit.java:357)
    at org.eclipse.jdt.internal.core.CompilationUnit.codeComplete(CompilationUnit.java:345)
    at org.eclipse.recommenders.internal.subwords.rcp.SubwordsSessionProcessor.computeProposals(SubwordsSessionProcessor.java:179)
    at org.eclipse.recommenders.internal.subwords.rcp.SubwordsSessionProcessor.getNewProposals(SubwordsSessionProcessor.java:151)
    at org.eclipse.recommenders.internal.subwords.rcp.SubwordsSessionProcessor.initializeContext(SubwordsSessionProcessor.java:108)
    at org.eclipse.recommenders.completion.rcp.processable.IntelligentCompletionProposalComputer.fireInitializeContext(IntelligentCompletionProposalComputer.java:218)
    at org.eclipse.recommenders.completion.rcp.processable.IntelligentCompletionProposalComputer.computeCompletionProposals(IntelligentCompletionProposalComputer.java:130)
    at org.eclipse.jdt.internal.ui.text.java.CompletionProposalComputerDescriptor.computeCompletionProposals(CompletionProposalComputerDescriptor.java:333)
    at org.eclipse.jdt.internal.ui.text.java.CompletionProposalCategory.computeCompletionProposals(CompletionProposalCategory.java:337)
    at org.eclipse.jdt.internal.ui.text.java.ContentAssistProcessor.collectProposals(ContentAssistProcessor.java:322)
    at org.eclipse.jdt.internal.ui.text.java.ContentAssistProcessor.computeCompletionProposals(ContentAssistProcessor.java:279)
    at org.eclipse.jface.text.contentassist.ContentAssistant$5.run(ContentAssistant.java:1904)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.jface.text.contentassist.ContentAssistant.computeCompletionProposals(ContentAssistant.java:1902)
    at org.eclipse.jface.text.contentassist.CompletionProposalPopup.computeProposals(CompletionProposalPopup.java:573)
    at org.eclipse.jface.text.contentassist.CompletionProposalPopup.access$16(CompletionProposalPopup.java:570)
    at org.eclipse.jface.text.contentassist.CompletionProposalPopup$2.run(CompletionProposalPopup.java:505)
    at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
    at org.eclipse.jface.text.contentassist.CompletionProposalPopup.showProposals(CompletionProposalPopup.java:499)
    at org.eclipse.jface.text.contentassist.ContentAssistant.showPossibleCompletions(ContentAssistant.java:1720)
    at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor$AdaptedSourceViewer.doOperation(CompilationUnitEditor.java:180)
    at org.eclipse.ui.texteditor.ContentAssistAction$1.run(ContentAssistAction.java:82)
    at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
    at org.eclipse.ui.texteditor.ContentAssistAction.run(ContentAssistAction.java:80)
    at org.eclipse.jface.action.Action.runWithEvent(Action.java:473)
    at org.eclipse.jface.commands.ActionHandler.execute(ActionHandler.java:122)
    at org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4HandlerProxy.java:90)
    at sun.reflect.GeneratedMethodAccessor193.invoke(null:-1)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:55)
    at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:247)
    at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:229)
    at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:132)
    at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.execute(HandlerServiceHandler.java:152)
    at org.eclipse.core.commands.Command.executeWithChecks(Command.java:499)
    at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:508)
    at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:210)
    at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.executeCommand(KeyBindingDispatcher.java:286)
    at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.press(KeyBindingDispatcher.java:507)
    at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.processKeyEvent(KeyBindingDispatcher.java:558)
    at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.filterKeySequenceBindings(KeyBindingDispatcher.java:378)
    at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.access$0(KeyBindingDispatcher.java:324)
    at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher$KeyDownFilter.handleEvent(KeyBindingDispatcher.java:86)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
    at org.eclipse.swt.widgets.Display.filterEvent(Display.java:1262)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1060)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1085)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1070)
    at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1112)
    at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1108)
    at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1529)
    at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:4764)
    at org.eclipse.swt.widgets.Canvas.WM_CHAR(Canvas.java:343)
    at org.eclipse.swt.widgets.Control.windowProc(Control.java:4645)
    at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:339)
    at org.eclipse.swt.widgets.Display.windowProc(Display.java:5042)
    at org.eclipse.swt.internal.win32.OS.DispatchMessageW(OS.java:-2)
    at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2549)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3759)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:1112)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:993)
    at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:156)
    at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:654)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:598)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:138)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethodAccessorImpl.java:-2)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1465)
   
  

General Information:

    reported-by:      Lukas Eder
    anonymous-id:     db231407-f5a0-4b36-b04d-38aa61d7e49a
    eclipse-build-id: 4.5.0.I20150320-0800
    eclipse-product:  org.eclipse.epp.package.java.product
    operating system: Windows8 6.2.0 (x86_64) - win32
    jre-version:      1.8.0_40-b25

The following plug-ins were present on the execution stack (*):
    1. org.eclipse.core.commands_3.6.100.v20150311-0214
    2. org.eclipse.core.databinding.observable_1.4.1.v20150311-0218
    3. org.eclipse.core.databinding_1.4.100.v20150311-0216
    4. org.eclipse.core.runtime_3.11.0.v20150316-1241
    5. org.eclipse.e4.core.commands_0.10.2.v20150313-1340
    6. org.eclipse.e4.core.contexts_1.3.100.v20150316-1240
    7. org.eclipse.e4.core.di_1.4.0.v20150316-1236
    8. org.eclipse.e4.ui.bindings_0.10.200.v20150313-1340
    9. org.eclipse.e4.ui.workbench_1.3.0.v20150316-1403
    10. org.eclipse.e4.ui.workbench.swt_0.12.100.v20150316-1403
    11. org.eclipse.equinox.app_1.3.200.v20130910-1609
    12. org.eclipse.equinox.launcher_1.3.0.v20140415-2008
    13. org.eclipse.jdt_3.11.0.v20150320-0800
    14. org.eclipse.jdt.core_3.11.0.v20150317-0048
    15. org.eclipse.jdt.ui_3.11.0.v20150316-2042
    16. org.eclipse.jface_3.11.0.v20150313-1544
    17. org.eclipse.jface.text_3.10.0.v20150112-1146
    18. org.eclipse.recommenders.completion.rcp_2.1.13.v20150323-0859
    19. org.eclipse.recommenders.subwords.rcp_2.1.13.v20150323-0859
    20. org.eclipse.swt_3.104.0.v20150319-1901
    21. org.eclipse.ui_3.107.0.v20150315-0703
    22. org.eclipse.ui.ide.application_1.0.600.v20150315-1254
    23. org.eclipse.ui.ide_3.11.0.v20150309-2044

Please note that:
* Messages, stacktraces, and nested status objects may be shortened.
* Bug fields like status, resolution, and whiteboard are sent
  back to reporters.
* The list of present bundles and their respective versions was
  calculated by package naming heuristics. This may or may not reflect reality.

Other Resources:
* Report: https://dev.eclipse.org/recommenders/committers/confess/#/problems/55367429e4b026254ee05e03  
* Manual: https://dev.eclipse.org/recommenders/community/confess/#/guide


Thank you for your assistance.
Your friendly error-reports-inbox.
Comment 1 Marcel Bruch CLA 2015-04-22 00:28:34 EDT
Moving to JDT core for review.
Comment 2 Manoj N Palat CLA 2015-04-22 01:22:08 EDT
(In reply to Marcel Bruch from comment #1)
> Moving to JDT core for review.
A code snippet reproducing the issue would be helpful
Comment 3 Lukas Eder CLA 2015-04-22 05:12:01 EDT
> A code snippet reproducing the issue would be helpful

You folks implemented this popup that just uploads stack traces in Eclipse Mars M6. That's what you get. Stack traces with no code snippets :-)

Anyway, I seem to be the one who caused this upload, and I'm pretty sure it has to do with something similar to the following:

----------------------------------------------------
public interface Test {
	@Annotation({X.AAAA, X.BBBB})
	void method();
}

@interface Annotation {
	X[] value() default {};
}

enum X {
	AAAA, BBBB, CCCC, DDDD
}
----------------------------------------------------

It then happened again, just now, when I was manipulating the list of values within the @Annotation({...}) usage:
https://dev.eclipse.org/recommenders/community/confess/#/incidents/LUXIsOCXDVEItQnhe0VMKBdeqEi4sR7GHCa78p0k3yjINXgNj4t05OQfBYjGly5G

Interesting thing: Up Eclipse Mars M5, I could autocomplete the following

----------------------------------------------------
public interface Test {
	@Annotation({AAAA/*auto-complete here to static-import*/, X.BBBB})
	void method();
}
----------------------------------------------------

This seems to be no longer possible, there's a regression somewhere when autocompleting values passed to annotations.
Comment 4 Jay Arthanareeswaran CLA 2015-04-22 07:47:50 EDT
Thanks Lukas. I investigated a bit and here's what is happening. 

When requesting for completion, we go about resolving the CU, in which both types Test and Annotation are declared. While resolving Test#method(), we see annotations and go about resolving the annotation (on the method). But in the process completion figures out that the node we are trying to solve is nothing but the node we are completing on and throws a CompletionNodeFound. This is fine, but as a result, the resolution of Test#method() is broken midway and we return from SourceTypeBinding#methods() without setting the returnType and this incomplete MethodBinding causes the NPE later.
Comment 5 Jay Arthanareeswaran CLA 2015-04-22 12:20:15 EDT
Assist also doesn't work for the following case:

public interface Test {
	@Annotation(AAAA|)
	void method();
}

This is most likely because in findEnumConstantsFromExpectedTypes() we see the expected type as an array type (of X) and conclude that it is not enum and don't look for enum constants.
Comment 6 Eclipse Genie CLA 2019-11-03 16:24:41 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.