This is probably a bad thing to do, as discussed in Can parent and child class in Java have same instance variable?. (What if the parent variable name is changed? Then it will not be shadowed anymore.) However, I am still curious whether variables that are differently static/nonstatic will shadow each other. On one hand I would expect they are the same variable name so would be shadowed, but on the other hand it seems like the compiler might distinguish between the two based on staticness.
Answer
From The Java Language Specification:
If an expression name consists of a single Identifier, then there
must be exactly one visible declaration denoting either a local
variable, parameter or field in scope at the point at which the the
Identifier occurs. Otherwise, a compile-time error occurs.If the declaration declares a final field, the meaning of the name is
the value of that field. Otherwise, the meaning of the expression name
is the variable declared by the declaration.
If a method in a superclass refers to a particular field (static or otherwise) of that class, only that class’s declaration of the field will be in scope at that point; any fields (static or otherwise) of subclasses will not be in scope. Therefore, the method will always use the superclass field, even if a subclass inherits it and shadows that field.
This answer is completely rewritten based on my new understanding of the question. Below is my first answer, kept for posterity.
From The Java Language Specification:
A declaration d of a field, local variable, method parameter,
constructor parameter or exception handler parameter named n shadows
the declarations of any other fields, local variables, method
parameters, constructor parameters or exception handler parameters
named n that are in scope at the point where d occurs throughout the
scope of d.
This suggests that compilers are required to shadow parent variables, regardless of staticness.
Note that none of this is relevant to inherited methods, which always use the original variables regardless of whether a subclass shadows them. I suspect this isn’t what you meant to ask.