Bug 464098 - NPE in CompletionProposalCollector.<init> (189)
Summary: NPE in CompletionProposalCollector.<init> (189)
Status: CLOSED DUPLICATE of bug 463860
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Recommenders (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Johannes Dorn CLA
QA Contact:
URL:
Whiteboard: Can you please provide more details w...
Keywords: needinfo
Depends on:
Blocks:
 
Reported: 2015-04-08 00:00 EDT by EPP Error Reports CLA
Modified: 2019-07-24 14:35 EDT (History)
3 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-08 00:00:06 EDT
The following incident was reported via the automated error reporting:


    code:                   1
    plugin:                 org.eclipse.recommenders.subwords.rcp_2.1.11.v20141027-2129
    message:                Exception during code completion
    fingerprint:            bcb8920d
    exception class:        java.lang.NullPointerException
    exception message:      -
    number of children:     0
    
    java.lang.NullPointerException: null
    at org.eclipse.jdt.ui.text.java.CompletionProposalCollector.<init>(CompletionProposalCollector.java:189)
    at org.eclipse.jdt.internal.ui.text.java.FillArgumentNamesCompletionProposalCollector.<init>(FillArgumentNamesCompletionProposalCollector.java:43)
    at org.eclipse.recommenders.completion.rcp.processable.ProposalCollectingCompletionRequestor.initalizeCollector(ProposalCollectingCompletionRequestor.java:56)
    at org.eclipse.recommenders.completion.rcp.processable.ProposalCollectingCompletionRequestor.<init>(ProposalCollectingCompletionRequestor.java:51)
    at org.eclipse.recommenders.internal.subwords.rcp.SubwordsSessionProcessor.computeProposals(SubwordsSessionProcessor.java:174)
    at org.eclipse.recommenders.internal.subwords.rcp.SubwordsSessionProcessor.getNewProposals(SubwordsSessionProcessor.java:148)
    at org.eclipse.recommenders.internal.subwords.rcp.SubwordsSessionProcessor.initializeContext(SubwordsSessionProcessor.java:105)
    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:325)
    at org.eclipse.jdt.internal.ui.text.java.ContentAssistProcessor.computeCompletionProposals(ContentAssistProcessor.java:282)
    at org.eclipse.jface.text.contentassist.ContentAssistant.computeCompletionProposals(ContentAssistant.java:1861)
    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:1687)
    at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor$AdaptedSourceViewer.doOperation(CompilationUnitEditor.java:183)
    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:519)
    at org.eclipse.jface.commands.ActionHandler.execute(ActionHandler.java:122)
    at org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4HandlerProxy.java:90)
    at sun.reflect.GeneratedMethodAccessor70.invoke(null:-1)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(null:-1)
    at java.lang.reflect.Method.invoke(null:-1)
    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:149)
    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:4722)
    at org.eclipse.swt.widgets.Canvas.WM_CHAR(Canvas.java:343)
    at org.eclipse.swt.widgets.Control.windowProc(Control.java:4610)
    at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:339)
    at org.eclipse.swt.widgets.Display.windowProc(Display.java:5023)
    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$9.run(PartRenderingEngine.java:1151)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1032)
    at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:148)
    at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:636)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:579)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:135)
    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:382)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:236)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(null:-2)
    at sun.reflect.NativeMethodAccessorImpl.invoke(null:-1)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(null:-1)
    at java.lang.reflect.Method.invoke(null:-1)
    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:      Nikolay Metchev
    anonymous-id:     7e94eadc-9077-32e2-8a41-c3f5581e059d
    eclipse-build-id: 4.4.0.I20140606-1215
    eclipse-product:  org.eclipse.epp.package.jee.product
    operating system: Windows8 6.2.0 (x86_64) - win32
    jre-version:      1.8.0_25-b18

The following plug-ins were present on the execution stack (*):
    1. org.eclipse.core.commands_3.6.100.v20140528-1422
    2. org.eclipse.core.databinding.observable_1.4.1.v20140210-1835
    3. org.eclipse.core.databinding_1.4.1.v20140214-0004
    4. org.eclipse.core.runtime_3.10.0.v20140318-2214
    5. org.eclipse.e4.core.commands_0.10.2.v20140424-2344
    6. org.eclipse.e4.core.contexts_1.3.100.v20140407-1019
    7. org.eclipse.e4.core.di_1.4.0.v20140414-1837
    8. org.eclipse.e4.ui.bindings_0.10.200.v20140424-2042
    9. org.eclipse.e4.ui.workbench_1.1.0.v20140528-1949
    10. org.eclipse.e4.ui.workbench.swt_0.12.100.v20140530-1436
    11. org.eclipse.equinox.app_1.3.200.v20130910-1609
    12. org.eclipse.equinox.launcher_1.3.0.v20140415-2008
    13. org.eclipse.jdt.ui_3.10.1.v20140817-1500
    14. org.eclipse.jdt_3.10.0.v20140925-0400
    15. org.eclipse.jface_3.10.0.v20140604-0740
    16. org.eclipse.jface.text_3.9.0.v20140521-1657
    17. org.eclipse.recommenders.completion.rcp_2.1.11.v20141027-2129
    18. org.eclipse.recommenders.subwords.rcp_2.1.11.v20141027-2129
    19. org.eclipse.swt_3.103.0.v20140605-2008
    20. org.eclipse.ui_3.106.0.v20140519-0906
    21. org.eclipse.ui.ide.application_1.0.500.v20140514-2033
    22. org.eclipse.ui.ide_3.10.0.v20140521-1937

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/54c4f314bee810030da0a9b9  
* 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-08 01:56:05 EDT
Johannes, can you investigate?
Comment 2 Andreas Sewe CLA 2015-04-08 03:55:44 EDT
Did some analysis.

The problematic lines seem to be

  JavaContentAssistInvocationContext newjdtContext = new JavaContentAssistInvocationContext(viewer, triggerOffset, editor);
  ICompilationUnit cu = newjdtContext.getCompilationUnit();

Here, according to the JavaDoc, cu can be null, which causes the NPE further down the line. (FWIW, JDT guards itself, against null ICompilationUnits in JavaCompletionProposalComputer.internalComputeCompletionProposals.)

I think the relevant change is f057e2b [1], which changed where the CU is taken from. Previously, it was

  ICompilationUnit cu = crContext.getCompilationUnit();

now it uses the newly created newJdtContext to get the CU from.

Interestingly, we can be sure to have a CU available (otherwise SubwordsSessionProcessor.initializeContext would fail), so I wonder why [1] uses the JavaContentAssistInvocationContext(viewer, triggerOffset, editor) constructor rather than JavaContentAssistInvocationContext(cu) with the CU off which we know that it is non-null?

Marcel, as you wrote the code in [1] initially, can you shed some light onto this?

[1] <https://git.eclipse.org/c/recommenders/org.eclipse.recommenders.git/commit/?id=f057e2b86f49d7cdfaab733f28e186313d346d8f>
Comment 3 Marcel Bruch CLA 2015-04-17 01:50:37 EDT
(In reply to Andreas Sewe from comment #2)

> Marcel, as you wrote the code in [1] initially, can you shed some light onto
> this?
> 
> [1]
> <https://git.eclipse.org/c/recommenders/org.eclipse.recommenders.git/commit/
> ?id=f057e2b86f49d7cdfaab733f28e186313d346d8f>



We need to set the invocation location. That's why I created a new context. I don't understand why there is an NPE b/c


public ICompilationUnit getCompilationUnit() {
if (!fCUComputed) {
...
IJavaElement je= EditorUtility.getEditorInputJavaElement(fEditor, false);
if (je instanceof ICompilationUnit)
 fCU= (ICompilationUnit)je;
}
...


'should' work. While I can think of a workaround, I'd like to further investigate and understand the situation where this happens. Maybe any of the reporters can provide an example. Will contact them.
Comment 4 Marcel Bruch CLA 2015-04-19 05:36:35 EDT

*** This bug has been marked as a duplicate of bug 463860 ***