Community
Participate
Working Groups
I've noticed that some of my enums fail to parse within Eclipse (3.1 11/2/04 integration build). After opening or while moving the cursor around within an offending file, I repeatedly get a dialog stating: 'An internal error occurred during: "Java AST creation".' Associated with this error I get following exception in the error log: java.lang.ClassCastException: org.eclipse.jdt.internal.compiler.ast.TypeDeclaration at org.eclipse.jdt.core.dom.ASTConverter.lookupScope(ASTConverter.java:3416) at org.eclipse.jdt.core.dom.ASTConverter.lookupForScopes(ASTConverter.java:3344) at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:1319) at org.eclipse.jdt.core.dom.CompilationUnitResolver.convert(CompilationUnitResolver.java:219) at org.eclipse.jdt.core.dom.ASTParser.internalCreateAST(ASTParser.java:743) at org.eclipse.jdt.core.dom.ASTParser.createAST(ASTParser.java:574) at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.createAST(ASTProvider.java:563) at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.getAST(ASTProvider.java:492) at org.eclipse.jdt.internal.ui.viewsupport.SelectionListenerWithASTManager$PartListenerGroup.calculateASTandInform(SelectionListenerWithASTManager.java:165) at org.eclipse.jdt.internal.ui.viewsupport.SelectionListenerWithASTManager$3.run(SelectionListenerWithASTManager.java:142) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:66) I believe the error occurs when an enum references static vars defined in other types from within its static initializer (there may be other cases). I've managed to come up with a reproducible test case, which I've pasted below. Put the two type definitions in two separate .java files in a project. Then open Test.java. After opening, click somewhere within the body of the enum. This should reproduce the error. public enum Test { VAL_A; private static final String VAL_A_LABEL; static { VAL_A_LABEL = Test2.value; } } public class Test2 { public static final String value = "foo"; }
I will investigate.
Fix is ready. Need to run all the tests before releasing it.
All tests are green (JDT/Core tests + JDT/UI tests).
Fixed and released in HEAD. Regression test added.
Ok for M3
Verified for 3.1 M3 with build I200411040800.