Supposing I have the following classes:
abstract class A {
static abstract class _Foo {}
}
class B extends A {
static void doSomething() {
System.out.println(C.saySomething());
}
static _Foo getInner() {
return new C._Foo();
}
static abstract class _Foo extends A._Foo {}
}
final class C extends D {
static String saySomething() {
return "Something";
}
}
abstract class D {
static class _Foo extends B._Foo {
public int value() {
return 42;
}
}
}
To provide some context:
- All of these classes reside in the same package.
- Class
CandDare generated at compile time - Class
Aas well asCare never instantiated; they simply provide some behaviour for classB - Class
Bis the only one that is actually used. - Class
Dis unknown until after compile time, which is why we are only usingCinB.
This is similar to what one might expect when working with google autovalue
My question is with regards to the getInner function in B:
- Which
_Foowill be instantiated at the linereturn new C._Foo();? The_FooinDor the one inA? - Is this undefined behaviour as to which gets instantiated or is it documented? Please provide documentation if possible
- How is the order determined?
The last question is just as an FYI, I'm mostly interested in the first two.
Thanks for your help.