-
Bug
-
Resolution: Fixed
-
P4
-
5.0
-
beta2
-
generic
-
solaris_7
-
Verified
The generic compiler allows overriding with a different primitive return
type, helpfully adding bridge methods. There is no support for that
behavior in the spec.
frog$ cat -n T.java
1 interface I {
2 double m();
3 }
4
5 abstract class J {
6 int m() { return 2; }
7 }
8
9 class K extends J implements I {
10 public short m() { return 1; }
11
12 public static void main(String[] args) {
13 K k = new K();
14 J j = k;
15 I i = k;
16 System.out.println(i.m() + " " + j.m() + " " + k.m());
17 }
18 }
frog$ newjavac T.java
frog$ jdis K.class
super class K
extends J
implements I
{
Method "<init>":"()V"
stack 1 locals 1
{
aload_0;
invokespecial Method J."<init>":"()V";
return;
}
public Method m:"()S"
stack 1 locals 1
{
iconst_1;
ireturn;
}
public static Method main:"([Ljava/lang/String;)V"
stack 4 locals 4
{
new class K;
dup;
invokespecial Method "<init>":"()V";
astore_1;
aload_1;
astore_2;
aload_1;
astore_3;
getstatic Field java/lang/System.out:"Ljava/io/PrintStream;";
new class java/lang/StringBuffer;
dup;
invokespecial Method java/lang/StringBuffer."<init>":"()V";
aload_3;
invokeinterface InterfaceMethod I.m:"()D", 1;
invokevirtual Method java/lang/StringBuffer.append:"(D)Ljava/lang/StringBuffer;";
ldc String " ";
invokevirtual Method java/lang/StringBuffer.append:"(Ljava/lang/String;)Ljava/lang/StringBuffer;";
aload_2;
invokevirtual Method J.m:"()I";
invokevirtual Method java/lang/StringBuffer.append:"(I)Ljava/lang/StringBuffer;";
ldc String " ";
invokevirtual Method java/lang/StringBuffer.append:"(Ljava/lang/String;)Ljava/lang/StringBuffer;";
aload_1;
invokevirtual Method m:"()S";
invokevirtual Method java/lang/StringBuffer.append:"(I)Ljava/lang/StringBuffer;";
invokevirtual Method java/lang/StringBuffer.toString:"()Ljava/lang/String;";
invokevirtual Method java/io/PrintStream.println:"(Ljava/lang/String;)V";
return;
}
public Method m:"()I"
stack 1 locals 1
{
aload_0;
invokevirtual Method m:"()S";
ireturn;
}
public Method m:"()D"
stack 2 locals 1
{
aload_0;
invokevirtual Method m:"()S";
i2d;
dreturn;
}
} // end Class K
frog$
type, helpfully adding bridge methods. There is no support for that
behavior in the spec.
frog$ cat -n T.java
1 interface I {
2 double m();
3 }
4
5 abstract class J {
6 int m() { return 2; }
7 }
8
9 class K extends J implements I {
10 public short m() { return 1; }
11
12 public static void main(String[] args) {
13 K k = new K();
14 J j = k;
15 I i = k;
16 System.out.println(i.m() + " " + j.m() + " " + k.m());
17 }
18 }
frog$ newjavac T.java
frog$ jdis K.class
super class K
extends J
implements I
{
Method "<init>":"()V"
stack 1 locals 1
{
aload_0;
invokespecial Method J."<init>":"()V";
return;
}
public Method m:"()S"
stack 1 locals 1
{
iconst_1;
ireturn;
}
public static Method main:"([Ljava/lang/String;)V"
stack 4 locals 4
{
new class K;
dup;
invokespecial Method "<init>":"()V";
astore_1;
aload_1;
astore_2;
aload_1;
astore_3;
getstatic Field java/lang/System.out:"Ljava/io/PrintStream;";
new class java/lang/StringBuffer;
dup;
invokespecial Method java/lang/StringBuffer."<init>":"()V";
aload_3;
invokeinterface InterfaceMethod I.m:"()D", 1;
invokevirtual Method java/lang/StringBuffer.append:"(D)Ljava/lang/StringBuffer;";
ldc String " ";
invokevirtual Method java/lang/StringBuffer.append:"(Ljava/lang/String;)Ljava/lang/StringBuffer;";
aload_2;
invokevirtual Method J.m:"()I";
invokevirtual Method java/lang/StringBuffer.append:"(I)Ljava/lang/StringBuffer;";
ldc String " ";
invokevirtual Method java/lang/StringBuffer.append:"(Ljava/lang/String;)Ljava/lang/StringBuffer;";
aload_1;
invokevirtual Method m:"()S";
invokevirtual Method java/lang/StringBuffer.append:"(I)Ljava/lang/StringBuffer;";
invokevirtual Method java/lang/StringBuffer.toString:"()Ljava/lang/String;";
invokevirtual Method java/io/PrintStream.println:"(Ljava/lang/String;)V";
return;
}
public Method m:"()I"
stack 1 locals 1
{
aload_0;
invokevirtual Method m:"()S";
ireturn;
}
public Method m:"()D"
stack 2 locals 1
{
aload_0;
invokevirtual Method m:"()S";
i2d;
dreturn;
}
} // end Class K
frog$