Community
Participate
Working Groups
----------------------------------A.java--------------------------- public class A { public A(final String str1, final String str2) { } private A[] methodA(final String str1, final String str2) { return new A[] { new A(str1, str2) { //initialiser! { methodA("1", "2"); } }, new A("hello".c) //<--------code complete to "hello".concat() }; } } --------------------------------------------------------------- if you code complete above to "hello".concat() you get: java.lang.NullPointerException at org.eclipse.jdt.internal.codeassist.CompletionEngine.computeExpectedTypes (CompletionEngine.java:3171) at org.eclipse.jdt.internal.codeassist.CompletionEngine.complete (CompletionEngine.java:415) at org.eclipse.jdt.internal.codeassist.CompletionEngine.complete (CompletionEngine.java:957) at org.eclipse.jdt.internal.core.Openable.codeComplete (Openable.java:133) at org.eclipse.jdt.internal.core.CompilationUnit.codeComplete (CompilationUnit.java:189) at org.eclipse.jdt.internal.core.CompilationUnit.codeComplete (CompilationUnit.java:183) at org.eclipse.jdt.internal.ui.text.java.ParameterGuesser$VariableCollector.collect (ParameterGuesser.java:132) at org.eclipse.jdt.internal.ui.text.java.ParameterGuesser.parameterProposals (ParameterGuesser.java:349) at org.eclipse.jdt.internal.ui.text.java.ParameterGuessingProposal.guessParameters (ParameterGuessingProposal.java:205) at org.eclipse.jdt.internal.ui.text.java.ParameterGuessingProposal.computeGuessingC ompletion(ParameterGuessingProposal.java:230) at org.eclipse.jdt.internal.ui.text.java.ParameterGuessingProposal.apply (ParameterGuessingProposal.java:121) at org.eclipse.jdt.internal.ui.text.java.JavaCompletionProposal.apply (JavaCompletionProposal.java:495) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.insertProposal (CompletionProposalPopup.java:333) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.selectProposalWithM ask(CompletionProposalPopup.java:302) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.verifyKey (CompletionProposalPopup.java:599) at org.eclipse.jface.text.contentassist.ContentAssistant$InternalListener.verifyKey (ContentAssistant.java:601) at org.eclipse.jface.text.TextViewer$VerifyKeyListenersManager.verifyKey (TextViewer.java:369) at org.eclipse.swt.custom.StyledTextListener.handleEvent (StyledTextListener.java:55) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:847) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:871) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:856) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:664) at org.eclipse.swt.custom.StyledText.handleKeyDown(StyledText.java:5310) at org.eclipse.swt.custom.StyledText$8.handleEvent(StyledText.java:5058) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:847) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:871) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:856) at org.eclipse.swt.widgets.Control.sendKeyEvent(Control.java:1689) at org.eclipse.swt.widgets.Control.sendKeyEvent(Control.java:1685) at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:3001) at org.eclipse.swt.widgets.Control.windowProc(Control.java:2889) at org.eclipse.swt.widgets.Display.windowProc(Display.java:2698) at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method) at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1343) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1861) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2106) at org.eclipse.ui.internal.Workbench.run(Workbench.java:2089) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:858) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:461) 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:298) at org.eclipse.core.launcher.Main.run(Main.java:764) at org.eclipse.core.launcher.Main.main(Main.java:598)
I can not reproduce the problem in build I20031009. Which build are you using ?
I200309300800
I can not reproduce in build I200309300800 Do you obtain the NPE with this exact test case ? The stack trace suggest that the code look like the following code. public class A { ... private A[] methodA() { ... X x = "hello".c ... } ... } And the NPE should occur because the type of the variable declaration should be null.
I just copied and pasted the exact test case and I got the NPE! That is definately the exact test case! If the latest integration build has no junit failures I will download it and try it on that!
I can confirm that the same things happens in M4!
I can reproduce the problem in 3.0M4. To reproduce it, "Fill argument names on method completion" must be enabled.
Fixed and regression test added.
Verified.