Bug 76328 - Using latest, NPE in codeassist
Summary: Using latest, NPE in codeassist
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: 3.1 M3   Edit
Assignee: David Audel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-10-14 21:29 EDT by Olivier Thomann CLA
Modified: 2004-11-04 06:25 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier Thomann CLA 2004-10-14 21:29:15 EDT
Trying to code assist for the field "length" for a array I get:
java.lang.NullPointerException
	at java.lang.String.<init>(String.java:244)
	at org.eclipse.jdt.internal.corext.util.TypeFilter.isFiltered(TypeFilter.java:44)
	at
org.eclipse.jdt.internal.ui.text.java.ResultCollector.acceptField(ResultCollector.java:118)
	at
org.eclipse.jdt.internal.codeassist.CompletionRequestorWrapper.accept(CompletionRequestorWrapper.java:118)
	at
org.eclipse.jdt.internal.codeassist.CompletionEngine.findFieldsAndMethods(CompletionEngine.java:1659)
	at
org.eclipse.jdt.internal.codeassist.CompletionEngine.complete(CompletionEngine.java:544)
	at
org.eclipse.jdt.internal.codeassist.CompletionEngine.complete(CompletionEngine.java:1080)
	at org.eclipse.jdt.internal.core.Openable.codeComplete(Openable.java:118)
	at
org.eclipse.jdt.internal.core.CompilationUnit.codeComplete(CompilationUnit.java:286)
	at
org.eclipse.jdt.internal.core.CompilationUnit.codeComplete(CompilationUnit.java:201)
	at
org.eclipse.jdt.internal.core.CompilationUnit.codeComplete(CompilationUnit.java:192)
	at
org.eclipse.jdt.internal.ui.text.java.JavaCompletionProcessor.internalComputeCompletionProposals(JavaCompletionProcessor.java:358)
	at
org.eclipse.jdt.internal.ui.text.java.JavaCompletionProcessor.computeCompletionProposals(JavaCompletionProcessor.java:332)
	at
org.eclipse.jface.text.contentassist.ContentAssistant.computeCompletionProposals(ContentAssistant.java:1472)
	at
org.eclipse.jface.text.contentassist.CompletionProposalPopup.computeProposals(CompletionProposalPopup.java:245)
	at
org.eclipse.jface.text.contentassist.CompletionProposalPopup.access$7(CompletionProposalPopup.java:241)
	at
org.eclipse.jface.text.contentassist.CompletionProposalPopup$1.run(CompletionProposalPopup.java:200)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:69)
	at
org.eclipse.jface.text.contentassist.CompletionProposalPopup.showProposals(CompletionProposalPopup.java:195)
	at
org.eclipse.jface.text.contentassist.ContentAssistant.showPossibleCompletions(ContentAssistant.java:1320)
	at
org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor$AdaptedSourceViewer.doOperation(CompilationUnitEditor.java:182)
	at org.eclipse.ui.texteditor.ContentAssistAction$1.run(ContentAssistAction.java:82)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:69)
	at org.eclipse.ui.texteditor.ContentAssistAction.run(ContentAssistAction.java:80)
	at org.eclipse.jface.action.Action.runWithEvent(Action.java:988)
	at org.eclipse.ui.commands.ActionHandler.execute(ActionHandler.java:188)
	at org.eclipse.ui.internal.commands.Command.execute(Command.java:130)
	at
org.eclipse.ui.internal.keys.WorkbenchKeyboard.executeCommand(WorkbenchKeyboard.java:463)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.press(WorkbenchKeyboard.java:956)
	at
org.eclipse.ui.internal.keys.WorkbenchKeyboard.processKeyEvent(WorkbenchKeyboard.java:997)
	at
org.eclipse.ui.internal.keys.WorkbenchKeyboard.filterKeySequenceBindings(WorkbenchKeyboard.java:541)
	at
org.eclipse.ui.internal.keys.WorkbenchKeyboard.access$2(WorkbenchKeyboard.java:488)
	at
org.eclipse.ui.internal.keys.WorkbenchKeyboard$1.handleEvent(WorkbenchKeyboard.java:241)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82)
	at org.eclipse.swt.widgets.Display.filterEvent(Display.java:748)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:799)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:824)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:809)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:837)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:833)
	at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1096)
	at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:3066)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:2977)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:3351)
	at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1489)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2441)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1443)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1414)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:271)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:144)
	at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:102)
	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:85)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:58)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:60)
	at java.lang.reflect.Method.invoke(Method.java:391)
	at org.eclipse.core.launcher.Main.basicRun(Main.java:185)
	at org.eclipse.core.launcher.Main.run(Main.java:684)
	at org.eclipse.core.launcher.Main.main(Main.java:668)
Comment 1 Olivier Thomann CLA 2004-10-14 23:04:13 EDT
Here is a test case:
public class X {
	public static void main(String[] args) {
		System.out.println(args.<COMPLETION HERE>);
	}
}

The problem is that CompletionProposal has no type package name and the
requestor is not expecting the null case. I don't know if the null case should
be handle. The API is not describing it.

ICompletionRequestor#acceptField(...) doesn't say that some parameters can be null.

If the null case is ok, then this is a bug in the client and this PR should be
moved to JDT/UI.

I set the severity to major since it is not possible to do any code assist for
an array (length, clone(), ...).
Comment 2 David Audel CLA 2004-10-15 10:08:59 EDT
Fixed.

Parameters must not be null. The ComplectionRequestorWrapper must return empty
array instead of null.
Comment 3 Frederic Fusier CLA 2004-11-04 06:25:04 EST
Verified for 3.1 M3 with build I200411040010 + jdt.core HEAD
Note that this problem does not occur in M2...