Bug 136946

Summary: [1.5][compiler] internal compiler error -- ArrayOutOfBoundException
Product: [Eclipse Project] JDT Reporter: Jon Barrilleaux <jonb>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: VERIFIED FIXED QA Contact:
Severity: blocker    
Priority: P3    
Version: 3.1.2   
Target Milestone: 3.2 RC2   
Hardware: PC   
OS: Windows 2000   
Whiteboard:
Attachments:
Description Flags
error log
none
source file that generates the error
none
Proposed fix
none
Better fix none

Description Jon Barrilleaux CLA 2006-04-16 21:18:40 EDT
Attched is the error log file with the stack trace, and the source file.  I suspect (gut feel) that the problem might be due to a base file using a subclass file as a delegate.
Comment 1 Jon Barrilleaux CLA 2006-04-16 21:20:17 EDT
Created attachment 38651 [details]
error log
Comment 2 Jon Barrilleaux CLA 2006-04-16 21:21:18 EDT
Created attachment 38652 [details]
source file that generates the error
Comment 3 Olivier Thomann CLA 2006-04-17 13:28:27 EDT
Small test case that reproduces the same stack trace.
public interface X<T> {	
	interface I1<T> extends X<T> {
		interface I2<T> extends I1<T> {
		}
	
		interface I3<T> extends I1<T> {
		}
		
		interface I4<T> extends I1.I2<T>, I1.I3<T> {	
		}
	}
}

If interface I1 doesn't extends X, it compiles fine.
javac 1.5.0_06 compiles the test case without a problem.
If all interfaces are not nested, then it works fine.

Using HEAD, I get three errors:
----------
1. ERROR in D:\tests_sources\X.java
 (at line 0)
	public interface X<T> {	
	^
Internal compiler error
java.lang.ArrayIndexOutOfBoundsException: -1
	at org.eclipse.jdt.internal.compiler.ast.ParameterizedQualifiedTypeReference.checkBounds(ParameterizedQualifiedTypeReference.java:55)
	at org.eclipse.jdt.internal.compiler.ast.ParameterizedQualifiedTypeReference.checkBounds(ParameterizedQualifiedTypeReference.java:47)
	at org.eclipse.jdt.internal.compiler.ast.ParameterizedQualifiedTypeReference.checkBounds(ParameterizedQualifiedTypeReference.java:47)
	at org.eclipse.jdt.internal.compiler.ast.ParameterizedQualifiedTypeReference.checkBounds(ParameterizedQualifiedTypeReference.java:40)
	at org.eclipse.jdt.internal.compiler.lookup.ClassScope.checkParameterizedTypeBounds(ClassScope.java:765)
	at org.eclipse.jdt.internal.compiler.lookup.ClassScope.checkParameterizedTypeBounds(ClassScope.java:775)
	at org.eclipse.jdt.internal.compiler.lookup.ClassScope.checkParameterizedTypeBounds(ClassScope.java:775)
	at org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.checkParameterizedTypes(CompilationUnitScope.java:204)
	at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.completeTypeBindings(LookupEnvironment.java:204)
	at org.eclipse.jdt.internal.compiler.Compiler.beginToCompile(Compiler.java:371)
	at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:385)
	at org.eclipse.jdt.internal.compiler.batch.Main.performCompilation(Main.java:2825)
	at org.eclipse.jdt.internal.compiler.batch.Main.compile(Main.java:1303)
	at org.eclipse.jdt.internal.compiler.batch.Main.compile(Main.java:1109)
	at org.eclipse.jdt.internal.compiler.batch.Main.compile(Main.java:1101)
	at org.eclipse.jdt.core.tools.compiler.Compile.main(Compile.java:19)

----------
2. ERROR in D:\tests_sources\X.java
 (at line 9)
	interface I4<T> extends I1.I2<T>, I1.I3<T> {	
	                        ^^^^^
The member type X<T>.I1.I2 cannot be qualified with a parameterized type, since it is static. Remove arguments from qualifying type X<T>.I1
----------
3. ERROR in D:\tests_sources\X.java
 (at line 9)
	interface I4<T> extends I1.I2<T>, I1.I3<T> {	
	                                  ^^^^^
The member type X<T>.I1.I3 cannot be qualified with a parameterized type, since it is static. Remove arguments from qualifying type X<T>.I1
----------
Comment 4 Philipe Mulet CLA 2006-04-18 06:47:49 EDT
2 issues:
1. no exception should occur
2. no error should be reported when resolving I1.I2<T> (shouln't complain about parameterized enclosing type X<T>).

Added GenericTypeTest#test0970
Comment 5 Philipe Mulet CLA 2006-04-18 06:50:56 EDT
Problem (1) comes from invalid recursion on enclosing type, where it should only check bounds of as long as there are some specified arguments (ParameterizedQualifiedTypeReference#checkBounds). 

Problem (2) comes from incorrect conversion to raw of I1 in ParameterizedQualifiedTypeReference#internalResolveType.

See attached patch.
Fixed
Comment 6 Philipe Mulet CLA 2006-04-18 06:52:22 EDT
Created attachment 38780 [details]
Proposed fix
Comment 7 Philipe Mulet CLA 2006-04-18 06:58:40 EDT
Created attachment 38781 [details]
Better fix
Comment 8 Olivier Thomann CLA 2006-04-27 23:11:44 EDT
Verified with I20060427-1600 for RC2.