Project: JDT
Bug 15330 NPE with quickfix
Reported: 2002-05-06 11:56:48 | Status: resolved fixed

build 0425 JButton desktop=new JButton("Hintergrund"); desktop.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JDesktopPane pane=SwingUtilities<ERROR>(JDesktopPane.class,this); } }); <ERROR> it should be SwingUtilities.getAnchestorOfClass Of course the above code snippet produceed an error and quickfix notified to have an idea. I pressed ctrl+1 and got informed it could create a method, short after that a NPE occured. org.eclipse.swt.SWTException: Failed to execute runnable (java.lang.StringIndexOutOfBoundsException: String index out of range: 0) at org.eclipse.swt.SWT.error(SWT.java:1887) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages (Synchronizer.java:96) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:1389) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1211) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:833) at org.eclipse.ui.internal.Workbench.run(Workbench.java:816) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:643) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:349) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:160) at org.eclipse.core.launcher.Main.run(Main.java:548) at org.eclipse.core.launcher.Main.main(Main.java:403) *** Stack trace of contained exception *** java.lang.StringIndexOutOfBoundsException: String index out of range: 0 at java.lang.String.charAt(String.java:516) at org.eclipse.jdt.internal.corext.codemanipulation.NameProposer.proposeParameterNa me(NameProposer.java:87) at org.eclipse.jdt.internal.ui.text.correction.NewMethodCompletionProposal.getParam eterNames(NewMethodCompletionProposal.java:199) at org.eclipse.jdt.internal.ui.text.correction.NewMethodCompletionProposal.generate Stub(NewMethodCompletionProposal.java:139) at org.eclipse.jdt.internal.ui.text.correction.NewMethodCompletionProposal.addEdits (NewMethodCompletionProposal.java:91) at org.eclipse.jdt.internal.ui.text.correction.CUCorrectionProposal.getChange (CUCorrectionProposal.java:58) at org.eclipse.jdt.internal.ui.text.correction.CUCorrectionProposal.getCompilationU nitChange(CUCorrectionProposal.java:132) at org.eclipse.jdt.internal.ui.text.correction.CUCorrectionProposal.getAdditionalPr oposalInfo(CUCorrectionProposal.java:74) at org.eclipse.jface.text.contentassist.AdditionalInfoController.computeInformation (AdditionalInfoController.java:185) at org.eclipse.jface.text.AbstractInformationControlManager.showInformation (AbstractInformationControlManager.java:536) at org.eclipse.jface.text.contentassist.AdditionalInfoController$1.run (AdditionalInfoController.java:145) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:29) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages (Synchronizer.java:93) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:1389) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1211) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:833) at org.eclipse.ui.internal.Workbench.run(Workbench.java:816) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:643) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:349) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:160) at org.eclipse.core.launcher.Main.run(Main.java:548) at org.eclipse.core.launcher.Main.main(Main.java:403)

Files changed in fix:
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/ASTResolving.java org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/NewMethodCompletionProposal.java