Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 6663588
Votes 0
Synopsis Compiler goes into infinite loop for Cyclic Inheritance test case
Category java:compiler
Reported Against
Release Fixed 7(b25)
State 10-Fix Delivered, bug
Priority: 2-High
Related Bugs
Submit Date 15-FEB-2008
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
Posted Date : 2008-02-15 07:14:38.0
Work Around
N/A
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.
Posted Date : 2008-02-15 17:14:29.0
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang