Bug 21447

Summary: Wrong method invoked at runtime
Product: [Eclipse Project] JDT Reporter: Philipe Mulet <philippe_mulet>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P2 CC: boris
Version: 2.0   
Target Milestone: 2.0.1   
Hardware: PC   
OS: Windows 2000   
Whiteboard:

Description Philipe Mulet CLA 2002-07-10 11:48:05 EDT
Build R2.0

On the following test case, the protected inner emulation seems incorrect since 
it leads to the wrong method invocation at runtime:

pa/X.java------------------
package pa;

public class X {
  protected void foo(){
    System.out.println("X.foo()");
  }
}

pb/T.java------------------
package pb;
import pa.X;

public class T extends X {
  public void bar(){
    new Object(){
      void do1(){
        T.this.foo();
      }
    }.do1();
  }
}

pb/Y.java------------------
package pb;
import pa.X;

public class Y extends T {

  public static void main(String[] args) {
    new Y().bar();
  }
	
  protected void foo(){
    System.out.println("Y.foo()");
  }
}

When running pb.Y, it should display "Y.foo()", but does display "X.foo()" 
instead. Same code compiled with javac 1.4.1 does display "Y.foo()" as expected.
Comment 1 Philipe Mulet CLA 2002-07-11 09:44:27 EDT
Problem is that the synthetic accessor for a method incorrectly diagnose a 
super method access (based on the fact the current class and the target method 
aren't part of the same class - this was true only for private access 
emulation, but not once protected jumped in).

Need to pass the information along, and generate separate access methods 
depending on whether the accessed method is used normally or with a super 
access so that the invocation bytecode is the right one.

Fixed in latest. 
Comment 2 Philipe Mulet CLA 2002-07-11 09:46:35 EDT
*** Bug 21482 has been marked as a duplicate of this bug. ***
Comment 3 David Audel CLA 2002-08-19 11:53:38 EDT
Verified.
Comment 4 Jerome Lanneluc CLA 2002-08-19 12:32:20 EDT
Verified
Comment 5 David Audel CLA 2002-09-20 09:13:56 EDT
Verified in 2.1 M1