Bug 77772 - [1.5] some enums failing to parse; internal error dialog pops up while typing
Summary: [1.5] some enums failing to parse; internal error dialog pops up while typing
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 critical (vote)
Target Milestone: 3.1 M3   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-11-03 17:03 EST by Khaled Agrama CLA
Modified: 2004-11-04 11:10 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Khaled Agrama CLA 2004-11-03 17:03:41 EST
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";
}
Comment 1 Olivier Thomann CLA 2004-11-03 18:09:47 EST
I will investigate.
Comment 2 Olivier Thomann CLA 2004-11-03 18:26:44 EST
Fix is ready. Need to run all the tests before releasing it.
Comment 3 Olivier Thomann CLA 2004-11-03 23:13:03 EST
All tests are green (JDT/Core tests + JDT/UI tests).
Comment 4 Olivier Thomann CLA 2004-11-03 23:13:22 EST
Fixed and released in HEAD.
Regression test added.
Comment 5 Philipe Mulet CLA 2004-11-04 05:32:58 EST
Ok for M3
Comment 6 Frederic Fusier CLA 2004-11-04 11:10:04 EST
Verified for 3.1 M3 with build I200411040800.