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: 4862621
Votes 0
Synopsis generics: incorrect cyclic inheritance error
Category java:compiler
Reported Against tiger
Release Fixed 1.5(tiger)
State 10-Fix Delivered, bug
Priority: 3-Medium
Related Bugs
Submit Date 12-MAY-2003
Description
...The following program fails to compile (1.0-1.3 prototypes) with an error
about "cyclic inheritance involving F":
---
class G<N extends Node<N>> {
    static class Node<N extends Node<N>> {
    }
}
class F extends G<MyNode> {
    static class MyNode extends G.Node<MyNode> {
    }
}
---
Making F.MyNode a separate class MyNode instead of an inner class fixes
the problem; see the attached sunbug.tgz for full details.  I can't read
the JLS definition of cyclic inheritance (JLS 8.1.3/9.1.2/14.3, although
8.1.3 is the only applicable section) as prohibiting this code in any
way, but then again 8.1.3 doesn't really state whether F.MyNode is meant
to "depend on" F or not.  The same program stripped of type parameters
(again, see sunbug.tgz) compiles without errors, which leads me to think
this is an error in how type parameters play into the cyclic inheritance
definition.

This is a relevant problem because it will arise in any definition of a
Graph interface using an inner class Graph.Node to represent nodes.  An
actual implementation of the interface will want to have code like the
above, leading to a confusing-at-best likely-erroneous situation.
Work Around
N/A
Evaluation
This should be fixed before Tiger beta.

 xxxxx@xxxxx  2003-05-12
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang