Project: JDT
Bug 204634 [code generation] NPE from content assist overriding method in anonymous subclass assigned to constant
Reported: 2007-09-25 22:42:03 | Status: resolved fixed

Build ID: I20070921-0919 Steps To Reproduce: Create the following class: public class OverrideBug { public static final OverrideBug bug = new OverrideBug() { foo| }; public void foo() { } } Put the cursor at the pipe, invoke content assist, and choose foo. Stack trace of the NPE created: java.lang.NullPointerException at org.eclipse.jdt.internal.corext.codemanipulation.StubUtility2.addOverrideAnnotation(StubUtility2.java:71) at org.eclipse.jdt.internal.corext.codemanipulation.StubUtility2.createImplementationStub(StubUtility2.java:453) at org.eclipse.jdt.internal.ui.text.java.OverrideCompletionProposal.updateReplacementString(OverrideCompletionProposal.java:142) at org.eclipse.jdt.internal.ui.text.java.JavaTypeCompletionProposal.apply(JavaTypeCompletionProposal.java:90) at org.eclipse.jdt.internal.ui.text.java.AbstractJavaCompletionProposal.apply(AbstractJavaCompletionProposal.java:456) 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:1165) at org.eclipse.jface.text.contentassist.ContentAssistant$InternalListener.verifyKey(ContentAssistant.java:789) at org.eclipse.jface.text.TextViewer$VerifyKeyListenersManager.verifyKey(TextViewer.java:460) at org.eclipse.swt.custom.StyledTextListener.handleEvent(StyledTextListener.java:60) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1512) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1536) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1521) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1312) at org.eclipse.swt.custom.StyledText.handleKeyDown(StyledText.java:5122) at org.eclipse.swt.custom.StyledText$7.handleEvent(StyledText.java:4813) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1512) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1536) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1521) at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1573) at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1568) at org.eclipse.swt.widgets.Control.kEventUnicodeKeyPressed(Control.java:2098) at org.eclipse.swt.widgets.Composite.kEventUnicodeKeyPressed(Composite.java:583) at org.eclipse.swt.widgets.Control.kEventTextInputUnicodeForKeyEvent(Control.java:2079) at org.eclipse.swt.widgets.Widget.textInputProc(Widget.java:1942) at org.eclipse.swt.widgets.Display.textInputProc(Display.java:3858) at org.eclipse.swt.internal.carbon.OS.SendEventToEventTarget(Native Method) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2975) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2389) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2353) at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2219) at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:466) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:289) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:461) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:106) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:169) 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:363) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:176) 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:585) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:515) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:455) at org.eclipse.equinox.launcher.Main.run(Main.java:1193) at org.eclipse.equinox.launcher.Main.main(Main.java:1169) Also, the content assist isn't actually executed. More information:

Files changed in fix:
org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/codemanipulation/GenerateHashCodeEqualsOperation.java org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/codemanipulation/StubUtility2.java