-
Bug
-
Resolution: Fixed
-
P3
-
5.0
-
b49
-
generic
-
solaris_8
It appears to be a bad idea to generify
class C implements Comparable { ... }
to
class C implements Comparable<C> { ... }
if C is not final. Suppose that D extends C and overrides compareTo(Object),
and that D is compiled with -source 1.4. Then any code compiled against the
new C and the old D with -source 1.5, including the code in C itself, will be
ignorant of D's override of compareTo(Object) since the compiler will choose
the more specific compareTo(C) defined in the new C class.
This generification is therefore incompatible, but the failure is silent.
It is possible for the compiler to give a diagnostic when D is
compiled. Specifically, the compiler could complain whenever a bridge
method is overridden. This is analogous to the situation of trying to
override a covariant method in -source 1.4, which is now forbidden.
Such a diagnostic should be added to help library vendors when
they encounter this situation.
It is an open question if this should be a warning of an error. I suggest
an error.
class C implements Comparable { ... }
to
class C implements Comparable<C> { ... }
if C is not final. Suppose that D extends C and overrides compareTo(Object),
and that D is compiled with -source 1.4. Then any code compiled against the
new C and the old D with -source 1.5, including the code in C itself, will be
ignorant of D's override of compareTo(Object) since the compiler will choose
the more specific compareTo(C) defined in the new C class.
This generification is therefore incompatible, but the failure is silent.
It is possible for the compiler to give a diagnostic when D is
compiled. Specifically, the compiler could complain whenever a bridge
method is overridden. This is analogous to the situation of trying to
override a covariant method in -source 1.4, which is now forbidden.
Such a diagnostic should be added to help library vendors when
they encounter this situation.
It is an open question if this should be a warning of an error. I suggest
an error.