Details
Description
Name: ngR10089 Date: 04/20/2004
The latest spec of "Adding Generics to the Java Programming Language: Final
Public Draft Specification, Version 1.01", 3.2 'Overriding' reads:
Otherwise, there are two possible cases:
o If one of the inherited methods is not abstract, then there are two
subcases:
- . . .
- Otherwise, the method that is not abstract is considered to override,
and therefore to implement, all the other methods on behalf of the
class that inherits it. A compile-time error occurs if, comparing
the method that is not abstract with each of the other of the inherited
methods, for any such pair, either the return type of one the methods
is not a subtype of the return type of the other or one has a return
type and the other is void. Moreover, a compile-time error occurs if
the inherited method that is not abstract has a throws clause that
conflicts with that of any other of the inherited methods.
o . . ."
In the case of multiple methods inheritence when one of the inherited methods
isn't abstract the spec doesn't require to compare return types for any two
abstract methods. According to assertion above test
lang/CLSS/clss442/clss44202/clss44202.html is valid.
However bug 5023148 'inheriting multiple abstract methods with unrelated return
types forbidden' was filed against this test.
The compiler behavior doesn't correspond to spec.
--------------- clss44202.java-------------
package javasoft.sqe.tests.lang.clss442.clss44202;
import java.io.PrintStream;
class clss44202b<A> {
public clss44202a<A> method(A v) {
return new clss44202a<A>(v);
}
}
interface clss44202i<A> {
clss44202i<A> method(A v);
}
interface clss44202j<A> {
clss44202j<A> method(A v);
}
class clss44202a<A> extends clss44202b<A> implements clss44202i<A>,
clss44202j<A> {
A value;
clss44202a(A v) {
value = v;
}
clss44202a() {
}
}
public class clss44202 {
public static void main(String argv[]) {
System.exit(run(argv, System.out) + 95/*STATUS_TEMP*/);
}
public static int run(String argv[],PrintStream out) {
clss44202a<Integer> a = new clss44202a<Integer>();
clss44202a<Integer> v = a.method(new Integer(5));
Integer i = v.value;
if(i.intValue() != 5) {
return 2/*STATUS_FAILED*/;
}
return 0/*STATUS_PASSED*/;
}
}
---------------------------------------
======================================================================