Could you give a few examples (code snippets) of obscuring?
I read the JLS, but I didn't understand the concept. JLS gives no code examples.
Hiding is between fields of Base and Derived class.
Shadowing is between a field and a local variable.
Obscuring - between what (?) and what (?)
SIDELINE: Interesting, JLS says that in case of hiding respective field from parent class is not inherited:
Shadowing is distinct from hiding (§8.3, §8.4.8.2, §8.5, §9.3, §9.5), which applies only to members which would otherwise be inherited but are not because of a declaration in a subclass. Shadowing is also distinct from obscuring (§6.4.2).
I also know that class names, method names and field names are all in their different namespaces:
// no problem/conflict with all three x's
class x {
void x() { System.out.println("all fine"); }
int x = 7;
}
EXAMPLES:
Finally found an example and some explanation of what is claimed to be obscuring (it causes compile error):
class C {
void m() {
String System = "";
// Line below won't compile: java.lang.System is obscured
// by the local variable String System = ""
System.out.println("Hello World"); // error: out can't be resolved
}
}
The above situation could be resolved by using the fully qualified name java.lang.System, or by statically importing System.out. If we happened to also have variables called java and out, neither of these workarounds would work and it would be impossible to access System.out.println.