-
Bug
-
Resolution: Fixed
-
P4
-
6u13
-
b114
-
x86
-
linux
-
Verified
FULL PRODUCT VERSION :
java version "1.6.0_13"
Java(TM) SE Runtime Environment (build 1.6.0_13-b03)
Java HotSpot(TM) 64-Bit Server VM (build 11.3-b02, mixed mode)
javac 1.6.0_13
ADDITIONAL OS VERSION INFORMATION :
2.6.28-13-generic #45-Ubuntu SMP Tue Jun 30 22:12:12 UTC 2009 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
The example code below (four variations) describes a conceptually valid class hierarchy, but in each case is prohibited by the JLS (8.1.4, 9.1.3: "A class C directly depends on a type T if T is mentioned in the extends or implements clause of C either as a superclass or superinterface, or AS A QUALIFIER of a superclass or superinterface name" ... "It is a compile-time error if a class depends on itself." -- emphasis mine.) Javac will compile two of the examples without error, and reports misleading errors in the other two cases.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile the following programs (cleaning up after any successful compiles to prevent javac from relying on previously-compiled class files):
*** Example 1
class a { static interface b {} }
class c extends a implements z.y {}
class x { static interface y {} }
class z extends x implements c.b {}
*** Example 2 (added another superinterface of c)
class a { static interface b { static interface d {} } }
class c extends a implements z.y, z.d {}
class x { static interface y {} }
class z extends x implements c.b {}
*** Example 3 (changed declaration order)
class x { static interface y {} }
class z extends x implements c.b {}
class a { static interface b { static interface d {} } }
class c extends a implements z.y, z.d {}
*** Example 4 (added another superinterface of z)
class a { static interface b { static interface d {} } }
class c extends a implements z.y, z.d {}
class x { static interface y { static interface w {} } }
class z extends x implements c.b, c.w {}
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
In each case, report a cyclical dependency in the declaration of the hierarchy. (Eclipse does this successfully.)
ACTUAL -
*** Example 1: [javac reports no error.]
*** Example 2: [javac reports no error.]
*** Example 3:
circular.java:5: cannot find symbol
symbol : class d
location: class z
class c extends a implements z.y, z.d {}
^
1 error
*** Example 4:
circular.java:6: cannot find symbol
symbol : class w
location: class c
class z extends x implements c.b, c.w {}
^
1 error
REPRODUCIBILITY :
This bug can be reproduced always.
java version "1.6.0_13"
Java(TM) SE Runtime Environment (build 1.6.0_13-b03)
Java HotSpot(TM) 64-Bit Server VM (build 11.3-b02, mixed mode)
javac 1.6.0_13
ADDITIONAL OS VERSION INFORMATION :
2.6.28-13-generic #45-Ubuntu SMP Tue Jun 30 22:12:12 UTC 2009 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
The example code below (four variations) describes a conceptually valid class hierarchy, but in each case is prohibited by the JLS (8.1.4, 9.1.3: "A class C directly depends on a type T if T is mentioned in the extends or implements clause of C either as a superclass or superinterface, or AS A QUALIFIER of a superclass or superinterface name" ... "It is a compile-time error if a class depends on itself." -- emphasis mine.) Javac will compile two of the examples without error, and reports misleading errors in the other two cases.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile the following programs (cleaning up after any successful compiles to prevent javac from relying on previously-compiled class files):
*** Example 1
class a { static interface b {} }
class c extends a implements z.y {}
class x { static interface y {} }
class z extends x implements c.b {}
*** Example 2 (added another superinterface of c)
class a { static interface b { static interface d {} } }
class c extends a implements z.y, z.d {}
class x { static interface y {} }
class z extends x implements c.b {}
*** Example 3 (changed declaration order)
class x { static interface y {} }
class z extends x implements c.b {}
class a { static interface b { static interface d {} } }
class c extends a implements z.y, z.d {}
*** Example 4 (added another superinterface of z)
class a { static interface b { static interface d {} } }
class c extends a implements z.y, z.d {}
class x { static interface y { static interface w {} } }
class z extends x implements c.b, c.w {}
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
In each case, report a cyclical dependency in the declaration of the hierarchy. (Eclipse does this successfully.)
ACTUAL -
*** Example 1: [javac reports no error.]
*** Example 2: [javac reports no error.]
*** Example 3:
circular.java:5: cannot find symbol
symbol : class d
location: class z
class c extends a implements z.y, z.d {}
^
1 error
*** Example 4:
circular.java:6: cannot find symbol
symbol : class w
location: class c
class z extends x implements c.b, c.w {}
^
1 error
REPRODUCIBILITY :
This bug can be reproduced always.
- relates to
-
JDK-7152962 Compiler misreporting cyclic inheritance
- Closed
-
JDK-7017837 Compiler binds base class incorrectly (shortcoming of base circularity spec)
- Open
-
JDK-4326631 Spurious Cyclic Inheritance Error
- Closed