Community
Participate
Working Groups
If in the advanced Java compiler options I select to receive warnings for "Local variable hides another field or variable", I get warnings when I make a static inner class that has a field with the same name as the enclosing class. But since the inner class is static, it doesn't make sense to say its field "hides" the field from the enclosing class. Example: public class FieldHideExample { String str; public static class Inner { String str; // compiler warning here Inner() { // but there is no hiding here, since Inner is a static class str = "test"; } } }
In the example, if the field "str" from the class "FieldHideExample" was static, then the warning should be issued indeed.
*** This bug has been marked as a duplicate of 51075 ***