Bug 85304 - [1.5] wrong declaring class for invokevirtual call
Summary: [1.5] wrong declaring class for invokevirtual call
Status: RESOLVED DUPLICATE of bug 85303
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-02-15 13:18 EST by Olivier Thomann CLA
Modified: 2005-02-16 06:59 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier Thomann CLA 2005-02-15 13:18:41 EST
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
Comment 1 Philipe Mulet CLA 2005-02-16 06:59:00 EST

*** This bug has been marked as a duplicate of 85303 ***