Project: JDT
Bug 133560 ClassCastException in quickfix
Reported: 2006-03-28 10:37:34 | Status: resolved fixed

Using I20060328-0010, I got the stack trace below. Steps to reproduce: 1) Create a new java project and set its preferences to 1.5. 2) Import JUnit sources in it (use the attached zip file) 3) Build the project 4) Go to junit.samples.VectorTest 5) Go to method testCapacity 6) The method has one warning. 7) Invoke quickfix and you should get this exception. org.eclipse.swt.SWTException: Failed to execute runnable (java.lang.ClassCastException: org.eclipse.jdt.core.dom.VariableDeclarationExpression) at org.eclipse.swt.SWT.error(SWT.java:3374) at org.eclipse.swt.SWT.error(SWT.java:3297) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:126) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3323) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2969) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1914) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1878) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:419) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:143) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:95) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:78) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:92) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:68) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:376) 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:585) at org.eclipse.core.launcher.Main.invokeFramework(Main.java:336) at org.eclipse.core.launcher.Main.basicRun(Main.java:280) at org.eclipse.core.launcher.Main.run(Main.java:975) at org.eclipse.core.launcher.Main.main(Main.java:950) Caused by: java.lang.ClassCastException: org.eclipse.jdt.core.dom.VariableDeclarationExpression at org.eclipse.jdt.internal.ui.text.correction.SurroundWith.moveToBlock(SurroundWith.java:343) at org.eclipse.jdt.internal.ui.text.correction.SurroundWith.getRewrite(SurroundWith.java:189) at org.eclipse.jdt.internal.ui.text.correction.SurroundWithRunnableProposal.getRewrite(SurroundWithRunnableProposal.java:104) at org.eclipse.jdt.internal.ui.text.correction.ASTRewriteCorrectionProposal.addEdits(ASTRewriteCorrectionProposal.java:90) at org.eclipse.jdt.internal.ui.text.correction.CUCorrectionProposal.createTextChange(CUCorrectionProposal.java:294) at org.eclipse.jdt.internal.ui.text.correction.CUCorrectionProposal.createChange(CUCorrectionProposal.java:303) at org.eclipse.jdt.internal.ui.text.correction.ChangeCorrectionProposal.getChange(ChangeCorrectionProposal.java:207) at org.eclipse.jdt.internal.ui.text.correction.CUCorrectionProposal.getTextChange(CUCorrectionProposal.java:313) at org.eclipse.jdt.internal.ui.text.correction.CUCorrectionProposal.getAdditionalProposalInfo(CUCorrectionProposal.java:131) at org.eclipse.jface.text.contentassist.AdditionalInfoController.computeInformation(AdditionalInfoController.java:221) at org.eclipse.jface.text.AbstractInformationControlManager.doShowInformation(AbstractInformationControlManager.java:820) at org.eclipse.jface.text.AbstractInformationControlManager.showInformation(AbstractInformationControlManager.java:810) at org.eclipse.jface.text.contentassist.AdditionalInfoController$1.run(AdditionalInfoController.java:173) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:123) ... 20 more

Files changed in fix:
org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest.java org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/SurroundWith.java