Bug 11037

Summary: DOM/AST: IllegalArgumentException when creating AST
Product: [Eclipse Project] JDT Reporter: Dirk Baeumer <dirk_baeumer>
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 2.0   
Target Milestone: 2.0 M4   
Hardware: PC   
OS: Windows 2000   
Whiteboard:

Description Dirk Baeumer CLA 2002-03-08 12:43:33 EST
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)
Comment 1 Olivier Thomann CLA 2002-03-08 12:46:46 EST
In general this means it is a missing case. Should be fixed quickly.
Comment 2 Olivier Thomann CLA 2002-03-08 13:03:43 EST
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.