Community
Participate
Working Groups
Tested with BETA_JAVA8 binaries updated today. What steps will reproduce the problem? 1. Add this class: public class AddThrows { interface Getter2<T, E extends Exception> { T get() throws E; } public static Long main2(Getter2<Long, ?> getter) { Long value = getter == null ? 0l : 1l; /* uncomment next line, then press CTRL-1 and * select either "add throws.." or "surround.." quick fix. */ //value = getter.get(); return value; } } 2. Uncomment the value = getter.get(); line. 3. Hover mouse over the uncommented line and select "Add throws declaration" quick fix. 4. The NPE is logged. Selecting "Surround with try/catch" also causes the same exception. Pressing CTRL-1 instead of hovering also causes the NPE, this time logged as a warning from jface.text. -- Error Details -- Date: Mon Dec 23 16:26:41 EET 2013 Message: Unhandled event loop exception Severity: Error Product: Eclipse SDK 4.3.1.v20130911-1000 (org.eclipse.sdk.ide) Plugin: org.eclipse.ui Session Data: eclipse.buildId=4.3.0.M20130911-1000 java.version=1.8.0-ea java.vendor=Oracle Corporation BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US Command-line arguments: -os win32 -ws win32 -arch x86_64 Exception Stack Trace: java.lang.NullPointerException at org.eclipse.jdt.internal.corext.dom.ASTNodeFactory.newType(ASTNodeFactory.java:142) at org.eclipse.jdt.internal.ui.text.correction.proposals.ChangeMethodSignatureProposal.modifyExceptions(ChangeMethodSignatureProposal.java:384) at org.eclipse.jdt.internal.ui.text.correction.proposals.ChangeMethodSignatureProposal.getRewrite(ChangeMethodSignatureProposal.java:138) at org.eclipse.jdt.ui.text.java.correction.ASTRewriteCorrectionProposal.addEdits(ASTRewriteCorrectionProposal.java:113) at org.eclipse.jdt.ui.text.java.correction.CUCorrectionProposal.createTextChange(CUCorrectionProposal.java:234) at org.eclipse.jdt.ui.text.java.correction.CUCorrectionProposal.createChange(CUCorrectionProposal.java:244) at org.eclipse.jdt.ui.text.java.correction.ChangeCorrectionProposal.getChange(ChangeCorrectionProposal.java:372) at org.eclipse.jdt.ui.text.java.correction.ChangeCorrectionProposal.performChange(ChangeCorrectionProposal.java:136) at org.eclipse.jdt.internal.ui.text.correction.proposals.LinkedCorrectionProposal.performChange(LinkedCorrectionProposal.java:150) at org.eclipse.jdt.ui.text.java.correction.CUCorrectionProposal.apply(CUCorrectionProposal.java:184) at org.eclipse.jdt.internal.ui.text.java.hover.AbstractAnnotationHover$AnnotationInformationControl.apply(AbstractAnnotationHover.java:538) at org.eclipse.jdt.internal.ui.text.java.hover.AbstractAnnotationHover$AnnotationInformationControl.access$2(AbstractAnnotationHover.java:515) at org.eclipse.jdt.internal.ui.text.java.hover.AbstractAnnotationHover$AnnotationInformationControl$5.widgetSelected(AbstractAnnotationHover.java:509) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:248) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1057) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1081) at org.eclipse.swt.widgets.Widget.sendSelectionEvent(Widget.java:1098) at org.eclipse.swt.widgets.Link.wmNotifyChild(Link.java:1084) at org.eclipse.swt.widgets.Control.wmNotify(Control.java:5617) at org.eclipse.swt.widgets.Composite.wmNotify(Composite.java:1935) at org.eclipse.swt.widgets.Control.WM_NOTIFY(Control.java:5169) at org.eclipse.swt.widgets.Control.windowProc(Control.java:4667) at org.eclipse.swt.widgets.Display.windowProc(Display.java:4990) at org.eclipse.swt.internal.win32.OS.CallWindowProcW(Native Method) at org.eclipse.swt.internal.win32.OS.CallWindowProc(OS.java:2443) at org.eclipse.swt.widgets.Link.callWindowProc(Link.java:172) at org.eclipse.swt.widgets.Widget.wmLButtonUp(Widget.java:2075) at org.eclipse.swt.widgets.Control.WM_LBUTTONUP(Control.java:4995) at org.eclipse.swt.widgets.Link.WM_LBUTTONUP(Link.java:922) at org.eclipse.swt.widgets.Control.windowProc(Control.java:4648) at org.eclipse.swt.widgets.Display.windowProc(Display.java:4977) at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method) at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2549) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3757) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1113) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:997) at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:138) at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:610) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:567) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:354) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:181) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591) at org.eclipse.equinox.launcher.Main.run(Main.java:1450) at org.eclipse.equinox.launcher.Main.main(Main.java:1426)
The bug is not particular to Java8 as it is reproducible even without the Java8 binaries in which case the same scenario results in IAE. The IAE thrown earlier is now changed to NPE as in ChangeMethodSignatureProposal the call to ASTNodeFactory.newName() is now changed to ASTNodeFactory.newType(). java.lang.IllegalArgumentException at org.eclipse.jdt.core.dom.SimpleName.setIdentifier(SimpleName.java:195) at org.eclipse.jdt.core.dom.AST.newSimpleName(AST.java:2046) at org.eclipse.jdt.core.dom.AST.newName(AST.java:1796) at org.eclipse.jdt.internal.corext.dom.ASTNodeFactory.newName(ASTNodeFactory.java:103) at org.eclipse.jdt.internal.ui.text.correction.proposals.ChangeMethodSignatureProposal.modifyExceptions(ChangeMethodSignatureProposal.java:380) at org.eclipse.jdt.internal.ui.text.correction.proposals.ChangeMethodSignatureProposal.getRewrite(ChangeMethodSignatureProposal.java:134) at org.eclipse.jdt.ui.text.java.correction.ASTRewriteCorrectionProposal.addEdits(ASTRewriteCorrectionProposal.java:113) at org.eclipse.jdt.ui.text.java.correction.CUCorrectionProposal.createTextChange(CUCorrectionProposal.java:234) at org.eclipse.jdt.ui.text.java.correction.CUCorrectionProposal.createChange(CUCorrectionProposal.java:244) at org.eclipse.jdt.ui.text.java.correction.ChangeCorrectionProposal.getChange(ChangeCorrectionProposal.java:372) at org.eclipse.jdt.ui.text.java.correction.CUCorrectionProposal.getTextChange(CUCorrectionProposal.java:254) at org.eclipse.jdt.ui.text.java.correction.CUCorrectionProposal.getAdditionalProposalInfo(CUCorrectionProposal.java:141) at org.eclipse.jface.text.contentassist.AdditionalInfoController$3.run(AdditionalInfoController.java:106) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
This issue seems to fixed along with bug 426868.
Yup, surround with.. gives ? as the type in the catch block but no NPEs.
(In reply to Timo Kinnunen from comment #3) > Yup, surround with.. gives ? as the type in the catch block but no NPEs. I see this behavior too and need to be fixed. Manju, is there already a bug for this?
(In reply to Jayaprakash Arthanareeswaran from comment #4) > (In reply to Timo Kinnunen from comment #3) > > Yup, surround with.. gives ? as the type in the catch block but no NPEs. > > I see this behavior too and need to be fixed. > > Manju, is there already a bug for this? That will be bug 350768. I will add the test case from comment 0 also to the bug so that it is not missed.
Not a dup of bug 350768. This is a complicated story, and the underlying issue was bug 217984 and bug 218645. Fixed with http://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=e2aeed82841a1b3bb2740000324b615485d8da59 Manju, could you please add a test case?
Created attachment 240944 [details] Test Markus, attached is the test for the bug.