Elliott Hughes
-
2004-09-02
- assigned_to: nobody --> enh
- status: open --> closed-duplicate
Compiling this (Jikes Compiler - Version 1.21 - 16 May 2004)
public class Test {
private int x;
public static void main( String arg[] ) {
int x;
}
}
I get
Issued 1 semantic warning compiling "Test.java":
6. int x;
^
*** Semantic Warning: Local "x" shadows a field of the same name in "Test".
I think this is wrong. There is no way to access the instance variable x from the static method main(), so there is no shadowing at all here.
This is very annoying for classes with main methods. Often one parses the command line assigning variables with the same name of instance variables that correspond to constructor parameters. jikes always emits warnings in that case.