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: 6695838
Votes 0
Synopsis javac does not detect cyclic inheritance involving static inner classes after import clause
Category java:compiler
Reported Against
Release Fixed 7(b34)
State 10-Fix Delivered, bug
Priority: 4-Low
Related Bugs
Submit Date 30-APR-2008
Description
I am still fighting with the cyclic inheritance problem and the fact that it gets compiled sometimes and other times it does not. It might be a bug in javac. Can somebody please take a look at this or tell me, whom I can contact for this issue?

For the bug to show, a class and an interface are needed:
sandbox/Foo.java:
<start code>
package sandbox;

class Foo implements Foo$Intf {
   
    public static interface Moo$Intf {}
   
}
<end code>

sandbox/Foo$Intf.java:
<start code>
package sandbox;

import sandbox.Foo.Moo$Intf;

public interface Foo$Intf extends Foo.Moo$Intf {}
<end code>


This is a dependency-cycle and violates therefore JLS 8.1.4. But calling "javac -cp . sandbox/Foo\$Intf.java" is successful. I tried it using the version of javac, which is part of the javafx-repository, jdk 1.6.0_03 and jdk 1.6.0_10.
Posted Date : 2008-04-30 00:23:50.0
Work Around
remove the import statement at in one of the two classes
Evaluation
The two class declarations are indeed cyclic; accordingly to JLS 8.1.4 we have that:

Foo depends on Foo$Intf (Foo$Intf appears in the implements clause of Foo)
Foo$Intf depends on Moo$Intf (Moo$Intf appears in the extends clause of Foo$Intf)
Foo$Intf depends on Foo (Foo appears as a qualifier in the extends clause of Foo$Intf)

For transitivity, we have that Foo depends on itself; as such the code should be rejected with a compile-time error.

This problem is due to the fact that when a toplevel class is completed in memberEnter, completion of import statements is triggered before the toplevel class symbol's UNATTRIBUTED flag is set. 

The code in Check that is in charge of detecting circularities rely upon the fact that such a flag has been set for all half-entered classes. If an half-entered class is found in the chain of superypes of a given class, this means that a circularity has just been detected (since supertypes' symbols are completed *ahead* of circularity checks).
Posted Date : 2008-06-24 13:32:45.0
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang