Community
Participate
Working Groups
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)
What do you expect? You don't even provide a compilation unit source.
We don't expect a valid AST (the bad source was clearly from a bug), but the method shouldn't blow up.
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.
Fixed recovery to filter out anonymous toplevel types during the updating phase. Regression test (DietRecoveryTest#test102) added. Fixed.