From Java Language Specification :
If the expression name consists of one identifier, then there must be exactly one visible declaration, denoting either a local variable, parameter or field in the area at the point at which the Identifier. Otherwise, a compile-time error occurs.
If the declaration declares a final field, the value of the name is the value of this field. Otherwise, the value of the expression name is a variable declared by the declaration.
If the method in the superclass refers to a specific field (static or otherwise) of this class, then only this class declaration in the field will be in this area; any fields (static or other) of subclasses will not possess. Therefore, the method will always use the superclass field, even if the subclass inherits it and obscures this field.
This answer has been completely rewritten based on my new understanding of the question. Below is my first answer saved for posterity.
From Java Language Specification :
Declaring a d field, local variable, method parameter, constructor parameter or exception handler parameter with the name n shadows declarations of any other fields, local variables, method parameters, constructor parameters or exception handler parameters n that are in scope at the point where d occurs throughout the volume d.
This suggests that compilers should shade parent variables regardless of static.
Note that this does not apply to legacy methods that always use source variables regardless of whether their subclass obscures. I suspect this is not what you wanted to ask.
Taymon
source share