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
*** Bug 85304 has been marked as a duplicate of this bug. ***
Tuned GenericTypeTest#test103. Added GenericTypeTest#test501-505. Fixed
Problem was due to special handling for extra bounds which did incorrectly fool generic cast insertions. Handling for extra bounds deals with code like: <? extends Object&IFoo>.foo() --> needs to checkcast to IFoo also discovered it did not perform well for field references (field, simple, qualified)
Verified in I20050330-0500