Community
Participate
Working Groups
Build 20020307 Test code: import java.util.List; public class Switch { public List fList; public void foo() { int i= 10; switch (i) { case 1: List l= null; break; default: } } } java.lang.IllegalArgumentException: Should not be reached: convert(class org.eclipse.jdt.internal.compiler.ast.LocalDeclaration) at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:1449) at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:1758) at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:1491) at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:590) at org.eclipse.jdt.core.dom.ASTConverter.buildBodyDeclarations (ASTConverter.java:215) at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:159) at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:73) at org.eclipse.jdt.core.dom.AST.parseCompilationUnit(AST.java:230) at org.eclipse.jdt.internal.corext.dom.JavaElementMapper.perform (JavaElementMapper.java:40) at org.eclipse.jdt.internal.corext.refactoring.sef.SelfEncapsulateFieldRefactoring. checkActivation(SelfEncapsulateFieldRefactoring.java:134) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate (RefactoringStarter.java:74) at org.eclipse.jdt.internal.ui.refactoring.actions.SelfEncapsulateFieldAction.run (SelfEncapsulateFieldAction.java:42) at org.eclipse.jface.action.Action.runWithEvent(Action.java:452) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:407)
In general this means it is a missing case. Should be fixed quickly.
I don't know why I was rejecting the case where a local declaration was a statement. This is naturally possible. In this example, List l = null; should be converted to a VariableDeclarationStatement. Fixed and released in HEAD.