Bug 85402 - [1.5][assist] NPE while trying to complete on empty annotation
Summary: [1.5][assist] NPE while trying to complete on empty annotation
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 M6   Edit
Assignee: David Audel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-02-16 08:50 EST by Frederic Fusier CLA
Modified: 2005-03-30 14:51 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 Frederic Fusier CLA 2005-02-16 08:50:14 EST
Using build 3.1 M5 candidate (I20040215-2300).
Having following test case:
Test.java:
  import e.Team;
  @Author(name={Team.DAVID, Team.JEROME})
  @| // <-- Try to complete here: NPE
  public class Test {
	@Author(name=Team.PHILIPPE) void foo() {}
	@Author int t;
  }
Author.java:
  import e.Team;
  public @interface Author {
	Team[] name() default Team.FREDERIC;
  }
Team.java:
  package e;
  public enum Team {
	PHILIPPE, DAVID, JEROME, FREDERIC;
  }

If you try to complete at caret position, then you get an Error Excuting Command
dialog.

Debug shows that there's a NPE in ResultCollector.accept(CompletionProposal)
method due to name==null for CompletionProposal
Comment 1 Frederic Fusier CLA 2005-02-16 08:53:24 EST
Here's NPE stack trace:
java.lang.NullPointerException
	at java.lang.String.<init>(String.java:166)
	at java.lang.String.valueOf(String.java:2145)
	at
org.eclipse.jdt.internal.ui.text.java.ResultCollector.accept(ResultCollector.java:734)
	at
org.eclipse.jdt.internal.codeassist.CompletionEngine.findTypesAndPackages(CompletionEngine.java:3623)
	at
org.eclipse.jdt.internal.codeassist.CompletionEngine.complete(CompletionEngine.java:929)
	at
org.eclipse.jdt.internal.codeassist.CompletionEngine.complete(CompletionEngine.java:1205)
	at org.eclipse.jdt.internal.core.Openable.codeComplete(Openable.java:119)
	at
org.eclipse.jdt.internal.core.CompilationUnit.codeComplete(CompilationUnit.java:287)
	at
org.eclipse.jdt.internal.core.CompilationUnit.codeComplete(CompilationUnit.java:280)
	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:1470)
	at
org.eclipse.jface.text.contentassist.CompletionProposalPopup.computeProposals(CompletionProposalPopup.java:250)
	at
org.eclipse.jface.text.contentassist.CompletionProposalPopup.access$7(CompletionProposalPopup.java:247)
	at
org.eclipse.jface.text.contentassist.CompletionProposalPopup$1.run(CompletionProposalPopup.java:206)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:69)
	at
org.eclipse.jface.text.contentassist.CompletionProposalPopup.showProposals(CompletionProposalPopup.java:201)
	at
org.eclipse.jface.text.contentassist.ContentAssistant.showPossibleCompletions(ContentAssistant.java:1319)
	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:69)
	at org.eclipse.ui.texteditor.ContentAssistAction.run(ContentAssistAction.java:80)
	at org.eclipse.jface.action.Action.runWithEvent(Action.java:1003)
	at org.eclipse.ui.commands.ActionHandler.execute(ActionHandler.java:182)
	at
org.eclipse.ui.internal.commands.LegacyHandlerWrapper.execute(LegacyHandlerWrapper.java:107)
	at org.eclipse.core.commands.Command.execute(Command.java:260)
	at
org.eclipse.ui.internal.keys.WorkbenchKeyboard.executeCommand(WorkbenchKeyboard.java:418)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.press(WorkbenchKeyboard.java:698)
	at
org.eclipse.ui.internal.keys.WorkbenchKeyboard.processKeyEvent(WorkbenchKeyboard.java:741)
	at
org.eclipse.ui.internal.keys.WorkbenchKeyboard.filterKeySequenceBindings(WorkbenchKeyboard.java:510)
	at
org.eclipse.ui.internal.keys.WorkbenchKeyboard.access$2(WorkbenchKeyboard.java:453)
	at
org.eclipse.ui.internal.keys.WorkbenchKeyboard$1.handleEvent(WorkbenchKeyboard.java:229)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82)
	at org.eclipse.swt.widgets.Display.filterEvent(Display.java:783)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:841)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:866)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:851)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:879)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:875)
	at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1181)
	at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:3121)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:3024)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:3480)
	at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1619)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2539)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1612)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1578)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:293)
	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:228)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:333)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:150)
	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.invokeFramework(Main.java:268)
	at org.eclipse.core.launcher.Main.basicRun(Main.java:260)
	at org.eclipse.core.launcher.Main.run(Main.java:887)
	at org.eclipse.core.launcher.Main.main(Main.java:871)
Comment 2 David Audel CLA 2005-02-21 12:33:54 EST
Fixed and test added 
  CompletionTest_1_5#test0087()

CompletionOnAnnotationOfType name must not be an empty array
Comment 3 Olivier Thomann CLA 2005-03-30 14:51:31 EST
The NPE is gone, but the proposal should only be annotations. This is a separate
issue reported in bug 89600.
Verified in I20050330-0500