Bug 12454 - AST/DOM: IllegalArgumentException generated by bad source
Summary: AST/DOM: IllegalArgumentException generated by bad source
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: Other other
: P3 normal (vote)
Target Milestone: 2.0 M5   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-03-28 12:03 EST by Jared Burns CLA
Modified: 2002-04-02 05:36 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jared Burns CLA 2002-03-28 12:03:44 EST
The following source (yes, it's bad) generates an IllegalArgumentException when
we try to parse it.

void ___eval() {
new Runnable(){
void ___run() throws Throwable {
return blah;
}
private String blarg;
public void run (){
}
}
;}
public class Hello{
private static int x;
private String blah;
public static void main (String[] args){
}
public void hello (){
}
public boolean blah (){
return false;}
public void foo (){
}
}

Here's the relevant part of the stack trace:

java.lang.IllegalArgumentException
	at org.eclipse.jdt.core.dom.SimpleName.setIdentifier(SimpleName.java:129)
	at org.eclipse.jdt.core.dom.AST.newSimpleName(AST.java:463)
	at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:137)
	at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:73)
	at org.eclipse.jdt.core.dom.AST.parseCompilationUnit(AST.java:330)
Comment 1 Olivier Thomann CLA 2002-03-28 12:23:41 EST
What do you expect? You don't even provide a compilation unit source. 
Comment 2 Jared Burns CLA 2002-03-28 13:07:20 EST
We don't expect a valid AST (the bad source was clearly from a bug), but the
method shouldn't blow up.
Comment 3 Olivier Thomann CLA 2002-03-28 14:23:56 EST
In fact this is a bug in the error recovery. The compilation unit declaration is 
returned with two types. One anonymous class and one class. An anonymous class 
cannot be a toplevel type. This doesn't work. I am expecting the beginning of 
the code to be ignore till the declaration of the class Hello.
The converter blew up trying to set the name of the anonymous type declaration.
Comment 4 Philipe Mulet CLA 2002-04-02 05:36:20 EST
Fixed recovery to filter out anonymous toplevel types during the updating 
phase. Regression test (DietRecoveryTest#test102) added.

Fixed.