Community
Participate
Working Groups
Build ID: I20090202-1535 Steps To Reproduce: 1. Place the caret in identifier 'bar' on LINE 11. 2. Press F3 (Open Declaration). See that the wrong method is opened. It should open X.bar() instead of E.bar(). More information: ------------- Bug.java --------------- class Bug{ enum E{ X{ @Override void bar(){ }}; void bar(){} } void foo(){ E.X. bar //LINE 11 (); } }
Looks like a bug when resolving the element.
Looks correct to me. The type of 'E.X' in 'E.X.bar()' is E, not the anonymous type. This becomes more clear if you change 'void bar(){}' in X to 'void bar2(){}' and then try to invoke 'E.X.bar2()' from outside. javac agrees with us that bar2() is not visible.
(In reply to comment #2) > Looks correct to me. > > The type of 'E.X' in 'E.X.bar()' is E, not the anonymous type. This becomes > more clear if you change 'void bar(){}' in X to 'void bar2(){}' and then try to > invoke 'E.X.bar2()' from outside. javac agrees with us that bar2() is not > visible. Yes. cf. public class Bug { static class E { public static final E X = new E() { void bar() {}}; void bar(){} } void foo(){ E.X.bar(); } }
Verified for 3.7M2.