Bug 99999 - [1.5][compiler] AIOOBE with generics + nested classes + arrays
Summary: [1.5][compiler] AIOOBE with generics + nested classes + arrays
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 3.1 RC3   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-06-14 12:09 EDT by Osvaldo Pinali Doederlein CLA
Modified: 2005-06-16 14:55 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Osvaldo Pinali Doederlein CLA 2005-06-14 12:09:07 EDT
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.
Comment 1 Olivier Thomann CLA 2005-06-14 14:30:15 EDT
I will investigate.
Comment 2 Philipe Mulet CLA 2005-06-14 15:06:04 EDT
+1 for RC3

Dani - pls vote for this one. A parser failure is pretty fatal to all our tooling.
Comment 3 Philipe Mulet CLA 2005-06-14 15:07:43 EDT
Osvaldo - you could have hit the commit button twice in a row, to get bug number
100.000 ! <g>
Comment 4 Osvaldo Pinali Doederlein CLA 2005-06-14 15:49:57 EDT
Well, I think 99999 is a lucky number for (hopefully) the last blocker in 3.1! ;)
Comment 5 Dani Megert CLA 2005-06-14 16:24:24 EDT
+1 for 3.1 RC3.
Comment 6 Olivier Thomann CLA 2005-06-15 09:15:45 EDT
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
Comment 7 Olivier Thomann CLA 2005-06-15 09:18:19 EDT
Regression tests are
org.eclipse.jdt.core.tests.compiler.regression.GenericTypeTest.test755/test756.

749 and 750 were already used when I wanted to release.
Comment 8 Olivier Thomann CLA 2005-06-16 14:55:21 EDT
Verified using N20050616-0010 + JDT/Core HEAD