Community
Participate
Working Groups
The following code bombs the compiler: public class A<T> { public static class B {} public static void main (String[] args) { A<?>.B[] b = new A<?>.B[1]; } } Steps to reproduce: 1) Create a class A 2) Paste the code above 3) Press CTRL+S to Save and compile Eclipse produces errors like this: !ENTRY org.eclipse.jdt.ui 4 0 2005-06-14 13:01:33.339 !MESSAGE Error in JDT Core during AST creation !STACK 0 java.lang.ArrayIndexOutOfBoundsException: -1 at org.eclipse.jdt.internal.compiler.parser.Parser.consumeArrayTypeWithTypeArgumentsName(Parser.java:1259) at org.eclipse.jdt.internal.compiler.parser.Parser.consumeRule(Parser.java:4581) at org.eclipse.jdt.internal.compiler.parser.Parser.parse(Parser.java:8488) at org.eclipse.jdt.internal.compiler.parser.Parser.parse(Parser.java:8739) at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.parseStatements(MethodDeclaration.java:116) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.parseMethod(TypeDeclaration.java:839) at org.eclipse.jdt.internal.compiler.parser.Parser.getMethodBodies(Parser.java:7818) at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:787) at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:498) at org.eclipse.jdt.core.dom.ASTParser.internalCreateAST(ASTParser.java:779) at org.eclipse.jdt.core.dom.ASTParser.createAST(ASTParser.java:588) at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider$1.run(ASTProvider.java:566) at org.eclipse.core.internal.runtime.InternalPlatform.run(InternalPlatform.java:1038) at org.eclipse.core.runtime.Platform.run(Platform.java:775) at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.createAST(ASTProvider.java:563) at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.getAST(ASTProvider.java:493) 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:76) then the file is saved, but I cannot open it anymore, even clicking in the class brings a new error dialog... apparently because RefactoringAvailabilityTester is trying to do some quick parsing to customize the contxt-sensitive menus. The problem doesn't happen if I don't create an array, or if I don't have the nesting (with the outer class being generic). It doesn't matter if I use some concrete type instead of '?'. But if I do a raw declaration A.B[], bug doesn't happen.
I will investigate.
+1 for RC3 Dani - pls vote for this one. A parser failure is pretty fatal to all our tooling.
Osvaldo - you could have hit the commit button twice in a row, to get bug number 100.000 ! <g>
Well, I think 99999 is a lucky number for (hopefully) the last blocker in 3.1! ;)
+1 for 3.1 RC3.
Fixed and released in HEAD. Regression test in org.eclipse.jdt.core.tests.compiler.regression.GenericTypeTest.test749/test750 and org.eclipse.jdt.core.tests.compiler.parser.GenericDietRecoveryTest.test0020. We know report: ----------\n" + "1. ERROR in A.java (at line 4)\r\n" + " A<?>.B[] b = new A<?>.B[1];\r\n" + " ^^^^^^\n" + "The member type A<?>.B cannot be qualified with a parameterized type, since it is static. Remove arguments from qualifying type A<?>\n" + "----------\n" + "2. ERROR in A.java (at line 4)\r\n" + " A<?>.B[] b = new A<?>.B[1];\r\n" + " ^^^^^^\n" + "The member type A<?>.B cannot be qualified with a parameterized type, since it is static. Remove arguments from qualifying type A<?>\n" + "----------\n
Regression tests are org.eclipse.jdt.core.tests.compiler.regression.GenericTypeTest.test755/test756. 749 and 750 were already used when I wanted to release.
Verified using N20050616-0010 + JDT/Core HEAD