Project: JDT
Bug 233278 [surround with] "Surround With runnable" crash.
Reported: 2008-05-21 13:05:04 | Status: resolved fixed

Build ID: I20080330-1350 (3.4M6) Steps To Reproduce: 1. Please select the text on lines 5-7. 2. On the "Surround With" menu, choose "runnable". See crash below... --------------- Bug.java ------------------ class Bug{{ final Integer x=0, y=1; new Object(){ void method(){ if(x==y)//LINE 5 return; toString();//LINE 7 }}; }} --------------------------------------------- java.lang.ArrayIndexOutOfBoundsException: 1 at org.eclipse.jdt.internal.corext.refactoring.code.flow.LocalFlowInfo.<init>(LocalFlowInfo.java:24) at org.eclipse.jdt.internal.corext.refactoring.code.flow.FlowAnalyzer.endVisit(FlowAnalyzer.java:766) at org.eclipse.jdt.core.dom.SimpleName.accept0(SimpleName.java:148) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2478) at org.eclipse.jdt.core.dom.ASTNode.acceptChild(ASTNode.java:2525) at org.eclipse.jdt.core.dom.InfixExpression.accept0(InfixExpression.java:367) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2478) at org.eclipse.jdt.core.dom.ASTNode.acceptChild(ASTNode.java:2525) at org.eclipse.jdt.core.dom.IfStatement.accept0(IfStatement.java:188) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2478) at org.eclipse.jdt.internal.corext.refactoring.code.flow.InOutFlowAnalyzer.perform(InOutFlowAnalyzer.java:40) at org.eclipse.jdt.internal.ui.text.correction.SurroundWith.getReads(SurroundWith.java:337) at org.eclipse.jdt.internal.ui.text.correction.SurroundWith.getVariableDeclarationReadsInside(SurroundWith.java:277) at org.eclipse.jdt.internal.ui.text.template.contentassist.SurroundWithTemplateProposal$SurroundWithTemplate.getVariableDeclarationReadsInside(SurroundWithTemplateProposal.java:79) at org.eclipse.jdt.internal.ui.text.correction.SurroundWith.getRewrite(SurroundWith.java:221) at org.eclipse.jdt.internal.ui.text.template.contentassist.SurroundWithTemplateProposal.createNewContext(SurroundWithTemplateProposal.java:244) at org.eclipse.jdt.internal.ui.text.template.contentassist.SurroundWithTemplateProposal.apply(SurroundWithTemplateProposal.java:198)

Files changed in fix:
org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/SurroundWithTemplateTest.java org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/dom/LocalVariableIndex.java