United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6663588 Compiler goes into infinite loop for Cyclic Inheritance test case
JDK-6663588 : Compiler goes into infinite loop for Cyclic Inheritance test case

Details
Type:
Bug
Submit Date:
2008-02-15
Status:
Closed
Updated Date:
2011-05-18
Project Name:
JDK
Resolved Date:
2011-05-18
Component:
tools
OS:
generic
Sub-Component:
javac
CPU:
generic
Priority:
P2
Resolution:
Fixed
Affected Versions:
7
Fixed Versions:

Related Reports
Relates:

Sub Tasks

Description
Description:
StackOverFlow Error while trying to compile the following Cyclic inheritance test code
If the bound to TypeParameter T is commented, Compiler works fine throwing cyclic inheritance error as expected.
<code>
bash-3.00$ cat Cyclic.java
class Cyclic <T extends Cyclic.Inn> extends Cyclic {

     class Inn extends Cyclic.Inn{

     }
}


</code>
Compilation result is :
<output>
The system is out of resources.
Consult the following stack trace for details.
java.lang.StackOverflowError
        at com.sun.tools.javac.code.Type$ClassType.accept(Type.java:568)
        at com.sun.tools.javac.code.Types$UnaryVisitor.visit(Types.java:3240)
        at com.sun.tools.javac.code.Types.supertype(Types.java:1605)
        at com.sun.tools.javac.comp.Resolve.findMemberType(Resolve.java:889)
        at com.sun.tools.javac.comp.Resolve.findMemberType(Resolve.java:891)
        at com.sun.tools.javac.comp.Resolve.findMemberType(Resolve.java:891)
        at com.sun.tools.javac.comp.Resolve.findMemberType(Resolve.java:891)
        at com.sun.tools.javac.comp.Resolve.findMemberType(Resolve.java:891)
        at com.sun.tools.javac.comp.Resolve.findMemberType(Resolve.java:891)
        at com.sun.tools.javac.comp.Resolve.findMemberType(Resolve.java:891)
        at com.sun.tools.javac.comp.Resolve.findMemberType(Resolve.java:891)
        at com.sun.tools.javac.comp.Resolve.findMemberType(Resolve.java:891)
        at com.sun.tools.javac.comp.Resolve.findMemberType(Resolve.java:891)
        at com.sun.tools.javac.comp.Resolve.findMemberType(Resolve.java:891)
        at com.sun.tools.javac.comp.Resolve.findMemberType(Resolve.java:891)
        at com.sun.tools.javac.comp.Resolve.findMemberType(Resolve.java:891)
        at com.sun.tools.javac.comp.Resolve.findMemberType(Resolve.java:891)


</output>
<version>
/net/sqindia/export/disk09/jdk/7/latest/binaries/solsparc/bin/java -version
java version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b24)
Java HotSpot(TM) Client VM (build 12.0-b01, mixed mode)

bash-3.00$ uname -a
SunOS hrajan 5.10 Generic sun4u sparc SUNW,Sun-Blade-100

                                    

Comments
SUGGESTED FIX

http://sa.sfbay.sun.com/projects/langtools_data/7/6663588/
                                     
2008-02-15
EVALUATION

Type-variable bounds might refer to classes belonging to a cyclic inheritance tree which causes the resolution process to enter a loop when looking up for symbols.

In this case, the resolution process hangs in method Resolve.findMemberType() when trying to attribute the declared bound of the type variable Cyclic.T. The resolution process is structured so that the entire inheritance tree (starting from the class in which the symbol is referenced) is browsed until a matching symbol is found. In this case this process never ends since the symbol Cyclic (the bound of Cyclic.T) is searched within the scope of Cyclic itself during the attribution of the bound of Cyclic.T. Since no such symbol is found within the scope of Cyclic, the resolver then tries to find the given symbol inside the scope of the Cyclic' supertype. However, since the supertype of Cyclic happens to be Cyclic itself, this causes the same method to be recusrively invoke with the same arguments.

The solution is to detect anomalies in the inheritance trees BEFORE starting the attribution of type variables.
                                     
2008-02-15



Hardware and Software, Engineered to Work Together