JDK-6273455 : crash: java.lang.StackOverflowError at com.sun.tools.javac.code.Types
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 5.0
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: generic,windows_xp
  • CPU: generic,x86
  • Submitted: 2005-05-20
  • Updated: 2010-04-02
  • Resolved: 2006-01-07
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6
6 b67Fixed
Related Reports
Duplicate :  
Description
This program doesn't compile and causes a stack overflow:

import java.util.*;

class Test<T extends Comparable<? super T>> {

    abstract class Group<E extends Comparable<? super E>> 
	extends ArrayList<E> 
	implements Comparable<Group<? extends E>> {}

    abstract class Sequence<E extends Comparable<? super E>>
	extends TreeSet<E>
	implements Comparable<Sequence<? extends E>> {}

    public void containsCombination(SortedSet<Group<T>> groups,
				    SortedSet<Sequence<T>> sequences) {
	foo(groups, sequences);
    }

    <C extends Collection<T>> void foo(SortedSet<? extends C> setToCheck,
				       SortedSet<? extends C> validSet) {}

}

###@###.### 2005-05-20 01:26:32 GMT
Stack overflow in 5.0u6:

The system is out of resources.
Consult the following stack trace for details.
java.lang.StackOverflowError
        at com.sun.tools.javac.code.Type.accept(Type.java:80)
        at com.sun.tools.javac.code.Types.lowerBound(Types.java:112)
        at com.sun.tools.javac.code.Types$IsSubTypeFcn.visitClassType(Types.java:410)
        at com.sun.tools.javac.code.Type$ClassType.accept(Type.java:482)
        at com.sun.tools.javac.code.Types$IsSubTypeFcn.isSubType(Types.java:347)

Comments
SUGGESTED FIX http://sa.sfbay.sun.com/projects/langtools_data/mustang/6273455/
26-01-2006

WORK AROUND Use explicit type argument: this.<Collection<T>>foo(groups, sequences); instead of: foo(groups, sequences); ###@###.### 2005-05-20 01:26:32 GMT
20-05-2005

EVALUATION This is a bug in inference causing creation of "infinite" wildcards. ###@###.### 2005-05-20 01:26:32 GMT
20-05-2005

SUGGESTED FIX Ensure that substitution doesn't create "infinite" ? extends ? extends ... T wildcards. Index: src/share/classes/com/sun/tools/javac/code/Types.java ============================================================ @@ -2126,9 +2126,12 @@ t = subst(t); if (t == that.type) result = that; - else + else { + if (t.isExtendsBound() && that.isExtendsBound()) + t = upperBound(t); result = new WildcardType(t, that.kind, syms.boundClass, that.bound); } + } public void visitArrayType(ArrayType t) { Type elemtype = subst(t.elemtype); ###@###.### 2005-05-20 01:26:32 GMT
20-05-2005