Community
Participate
Working Groups
In GenericTypeTest.test103, we changed the declaring class to solve a VerifyError problem. I think we should generate a checkcast instead. public class X <T extends AX> { T t; X(T t){ this.t = t; } public static void main(String[] args) { X<BX<String>> x = new X<BX<String>>(new BX<String>()); x.t.foo("SUCC"); x.t.bar("ESS"); } } class AX<P> { void foo(P p) { System.out.print(p); } } class BX<Q> extends AX<Q> { void bar(Q q) { System.out.println(q); } } We generate: 0 new X [2] 3 dup 4 new BX [27] 7 dup 8 invokespecial BX.<init>()V [28] 11 invokespecial X.<init>(LAX;)V [30] 14 astore_1 [x] 15 aload_1 [x] 16 getfield X.t LAX; [17] 19 ldc <String "SUCC"> [32] 21 invokevirtual AX.foo(Ljava/lang/Object;)V [38] 24 aload_1 [x] 25 getfield X.t LAX; [17] 28 checkcast BX [27] 31 ldc <String "ESS"> [40] 33 invokevirtual BX.bar(Ljava/lang/Object;)V [43] 36 return The lines: 16 getfield X.t LAX; [17] 19 ldc <String "SUCC"> [32] 21 invokevirtual AX.foo(Ljava/lang/Object;)V [38] are wrong. We should not change the declaring class to be AX. It should be BX. We should generate something like this: 0 new X [2] 3 dup 4 new BX [27] 7 dup 8 invokespecial BX.<init>()V [28] 11 invokespecial X.<init>(LAX;)V [30] 14 astore_1 [x] 15 aload_1 [x] 16 getfield X.t LAX; [17] 19 checkcast BX [27] 21 ldc <String "SUCC"> [32] invokevirtual BX.foo(Ljava/lang/Object;)V [36] aload_1 [x] getfield X.t LAX; [17] checkcast BX [27] ldc <String "ESS"> [38] invokevirtual BX.bar(Ljava/lang/Object;)V [41] return
*** This bug has been marked as a duplicate of 85303 ***