Community
Participate
Working Groups
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.
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.
*** Bug 21482 has been marked as a duplicate of this bug. ***
Verified.
Verified
Verified in 2.1 M1