Community
Participate
Working Groups
Build id: I20070228-0930 Trying to complete in code below where RED, I selected 'DataChangeList<T>' and nothing got inserted, but a NPE got dumped into the console. ------------------------------ import java.util.ArrayList; import java.util.List; class ArchiveRecordList<R extends ArchiveRecord> extends ArrayList<R> { @Override public ArchiveRecordList<R> subList(int fromIndex, int toIndex) { return (ArchiveRecordList<R>)super.subList(fromIndex, toIndex); } } class DataChangeList<T> extends ArchiveRecordList<DataChangeRecord<T>> { public DataChangeList<T> getDataBetween(long from, long to) { return (Data[ASSIST-HERE]subList(indexOf(from), indexOf(to) + 1); } } class IntDataChangeList extends DataChangeList<Integer> { public IntDataChangeList getDataBetween(long from, long to) { return super.getDataBetween(from, to); } } class DblDataChangeList extends DataChangeList<Double> { public DblDataChangeList getDataBetween(long from, long to) { return super.getDataBetween(from, to); } } class ArchiveRecord {} class DataChangeRecord<T> extends ArchiveRecord {} ========================= !ENTRY org.eclipse.ui 4 0 2007-03-13 10:11:41.858 !MESSAGE Unhandled event loop exception !STACK 0 java.lang.NullPointerException at org.eclipse.jdt.internal.core.util.BindingKeyResolver.consumeTypeVariable(BindingKeyResolver.java:348) at org.eclipse.jdt.internal.core.util.BindingKeyParser.parseTypeVariable(BindingKeyParser.java:823) at org.eclipse.jdt.internal.core.util.BindingKeyParser.parse(BindingKeyParser.java:591) at org.eclipse.jdt.internal.core.util.BindingKeyParser.parse(BindingKeyParser.java:529) at org.eclipse.jdt.internal.core.util.BindingKeyParser.parseTypeArgument(BindingKeyParser.java:796) at org.eclipse.jdt.internal.core.util.BindingKeyParser.parseParameterizedType(BindingKeyParser.java:752) at org.eclipse.jdt.internal.core.util.BindingKeyParser.parse(BindingKeyParser.java:561) at org.eclipse.jdt.internal.core.util.BindingKeyParser.parse(BindingKeyParser.java:529) at org.eclipse.jdt.internal.core.util.BindingKeyResolver.getCompilerBinding(BindingKeyResolver.java:446) at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:790) at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:466) at org.eclipse.jdt.core.dom.ASTParser.createASTs(ASTParser.java:705) at org.eclipse.jdt.internal.ui.text.java.LazzyGenericTypeProposal.getExpectedType(LazzyGenericTypeProposal.java:602) at org.eclipse.jdt.internal.ui.text.java.LazzyGenericTypeProposal.computeTypeArgumentProposals(LazzyGenericTypeProposal.java:298) at org.eclipse.jdt.internal.ui.text.java.LazzyGenericTypeProposal.apply(LazzyGenericTypeProposal.java:195) at org.eclipse.jdt.internal.ui.text.java.AbstractJavaCompletionProposal.apply(AbstractJavaCompletionProposal.java:453) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.insertProposal(CompletionProposalPopup.java:806) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.insertSelectedProposalWithMask(CompletionProposalPopup.java:757) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.verifyKey(CompletionProposalPopup.java:1164) at org.eclipse.jface.text.contentassist.ContentAssistant$InternalListener.verifyKey(ContentAssistant.java:782) at org.eclipse.jface.text.TextViewer$VerifyKeyListenersManager.verifyKey(TextViewer.java:438) at org.eclipse.swt.custom.StyledTextListener.handleEvent(StyledTextListener.java:61) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:938) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:962) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:947) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:706) at org.eclipse.swt.custom.StyledText.handleKeyDown(StyledText.java:5075) at org.eclipse.swt.custom.StyledText$7.handleEvent(StyledText.java:4817) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:938) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:962) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:947) at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:975) at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:971) at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1285) at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:3601) at org.eclipse.swt.widgets.Control.windowProc(Control.java:3501) at org.eclipse.swt.widgets.Display.windowProc(Display.java:4308) at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method) at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2209) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3251) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2306) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2270) at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2145) at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:460) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:289) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:455) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:101) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:146) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:106) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:76) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:354) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:169) 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:597) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:476) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:416) at org.eclipse.equinox.launcher.Main.run(Main.java:1124) at org.eclipse.equinox.launcher.Main.main(Main.java:1099)
Reproduced in debugger: offending signature looks like: LX~DataChangeList<LX~DataChangeList;:TT;>;
Issue is located on line marked with '>>>>>>>' since both methodBinding and typeBinding are null. public void consumeTypeVariable(char[] position, char[] typeVariableName) { if (position.length > 0) { int pos = Integer.parseInt(new String(position)); MethodBinding[] methods = ((ReferenceBinding) this.typeBinding).methods(); if (methods != null && pos < methods.length) { this.methodBinding = methods[pos]; } } >>>>>>> TypeVariableBinding[] typeVariableBindings = this.methodBinding != null ? this.methodBinding.typeVariables() : this.typeBinding.typeVariables(); for (int i = 0, length = typeVariableBindings.length; i < length; i++) { TypeVariableBinding typeVariableBinding = typeVariableBindings[i]; if (CharOperation.equals(typeVariableName, typeVariableBinding.sourceName())) { this.typeBinding = typeVariableBinding; return; } } }
Missing step: the unit file name was "X.java". Looks like the decoding doesn't handle situation where no 'X' type is actually present in the unit. Feels like the support for finding secondary types could be used directly, instead of relying on ability to find a primary type.
To reproduce: 1. Start a new workspace on a 1.5 VM 2. Create a new Java project (verify that compliance is 1.5) 3. Create a new type X in the default package 4. In the X.java editor, replace the whole content with: class Y<T> { public Y<T> foo() { return Y//complete here } } 5. Code complete after 2nd Y Observe: you get the NPE reported above in the .log
Changed BindingKeyParser to parse the secondary type name before pausing after fully qualified name parsing. Changed BindingKeyResolver to handle null binding when looking up the primary type binding, and to default to use the secondary type lookup. Added regression test BatchASTCreationTests#test083(). Released for 3.3M6 in HEAD.
*** Bug 86990 has been marked as a duplicate of this bug. ***
Pls backport to 3.2.x stream.
Created attachment 60778 [details] Corresponding reverse patch To apply, choose the Reverse patch option in the Apply patch wizard.
Patch applied in R3_2_maintenance stream (no target milestone yet)
Verified for 3.3 M6 using build I20070319-1335.
> Verified for 3.3 M6 using build I20070319-1335. >