Is there any way to access a static member of a nested class from the enclosing class when the nested class shares a name with a static member of the enclosing class? For example:
package a;
class a {
static Object b;
static class b {
static Object foo;
}
static Object needAccessToFoo;
static {
// can I access foo?
}
}
The class b (as opposed to the member b) can be accessed when being used as a Type via a (or [b.]b.a). And foo can be accessed using the instance of the nested class b as so:
static {
[a.][a.]b bar = new b();
needAccessToFoo = bar.foo;
}
However, since b is a nested class and not an inner class, it leaves one to wonder if there is a proper way to statically reference foo without going through an instance of b (the object referred to by bar). Not to mention it's generally accepted as bad practice to access a static member via an object.
Bfor the class andbfor the field? ;)