Bug 100128

Summary: [1.5][compiler] StackOverflow compiling GNU Classpath generics branch
Product: [Eclipse Project] JDT Reporter: Jeroen Frijters <jeroen>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert, maxime_daniel
Version: 3.1   
Target Milestone: 3.1 RC3   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Apply patch on CaptureBinding none

Description Jeroen Frijters CLA 2005-06-15 03:34:43 EDT
When compiling the generics branch of GNU Classpath (a free Java class library 
implementation) ecj dies with a StackOverflow:

----------
1. ERROR in ..\..\classpath-generics\java\util\EnumMap.java
 (at line 0)
        /* EnumMap.java - Map where keys are enum constants
        ^
Internal compiler error
java.lang.StackOverflowError
        at
org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding.erasure(Typ
eVariableBinding.java:257)
        at
org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding.erasure(Typ
eVariableBinding.java:257)
        at
org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding.erasure(Typ
eVariableBinding.java:257)
        <... hunderds more deleted ...>
Comment 1 Jeroen Frijters CLA 2005-06-15 03:41:33 EDT
A snapshot of the GNU Classpath generics branch (ready to compile) is 
available here: http://www.frijters.net/bug100128.zip

Unzip and compile using:
ecj -1.5 -nowarn @src.lst
Comment 2 Philipe Mulet CLA 2005-06-15 06:37:24 EDT
+1 for RC3

Dani - pls cast a vote. You know how an Error is bad.
Comment 3 Dani Megert CLA 2005-06-15 07:00:18 EDT
+1 to fix this in 3.1 RC3.
Comment 4 Philipe Mulet CLA 2005-06-15 07:07:02 EDT
Created attachment 23158 [details]
Apply patch on CaptureBinding

I suspect issue arises due to capture creating a cyclic supertype (which
erasure is then falling into), as firstBound isn't protected for cycle
detection.
Comment 5 Philipe Mulet CLA 2005-06-15 07:07:48 EDT
Maxime - pls obtain a simpler testcase reproducing it.
Comment 6 Jeroen Frijters CLA 2005-06-15 10:53:21 EDT
Thanks! The patch seems to work.
Comment 7 Maxime Daniel CLA 2005-06-15 12:33:15 EDT
Shorter test case:
public class X<E>
{
  E[] m;
  public X()
  {
	X<? extends E> x = null;
	System.out.println(x.m.length);
  }
}
Comment 8 Philipe Mulet CLA 2005-06-15 12:34:31 EDT
Thanks for confirming. Also note that another issue got addressed within your
source lib (see bug 100147).
Comment 9 Philipe Mulet CLA 2005-06-15 12:37:27 EDT
Thanks Maxime. Added GenericTypeTest#test759.
Fixed
Comment 10 Olivier Thomann CLA 2005-06-16 14:38:58 EDT
Verified using N20050616-0010 + JDT/Core HEAD.
The attached project contains 3 compile errors, but no more internal compile errors.
Comment 11 Olivier Thomann CLA 2005-06-16 14:39:10 EDT
Verified using N20050616-0010 + JDT/Core HEAD