Community
Participate
Working Groups
Build Identifier: M20110909-1335 Consider the following program: public class A { int f = 42; int foo() { int r = f; int f = 23; return r; } public static void main(String[] args) { System.out.println(new A().foo()); } } This program prints "42". Note that the reference to field "f" in the initialiser of local variable "r" is shadowed later on by the local variable "f". Inlining local variable "r" yields the following program: public class A { int f = 42; int foo() { int f = 23; return f; // should be "return this.f;" } public static void main(String[] args) { System.out.println(new A().foo()); } } This is wrong: the program now prints "23", since the reference "f" now refers to the local variable. Reproducible: Always Steps to Reproduce: See above description.
*** This bug has been marked as a duplicate of bug 367536 ***