Well, I've got such a code:
public class Main {
public static void main(String[] args) {
Test t; //1
Integer i = new Integer(1); //2
t = new Test(); //3
System.out.println(Test4.a); //4
}
}
class Test {
private int a = 10;
private Test2 t2; //5
List<Test2> list = new ArrayList<Test2>() {
{
for (int i = 0; i < a; i++) {
add(new Test2()); //6
}
}
};
}
class Test2 extends Test3{
}
class Test3 {
}
class Test4 {
public static final int a = 4;
}
I don't know how (fully or partially) and when classes are loaded. So:
Test t;- it is not an active usage, but the referencetmust be a definite type of. Was Test class loaded (maybe partially, then how many stages - loading\linking\initializing - it passed) or nothing happened?Integer i = new Integer(1);- was Integer loaded when JVM starts or on this line?t = new Test();- an active usage. Was it loaded fully from the beginning or from some point (see 1)System.out.println(Test4.a);- wasTest4loaded or not?- Were
Test2andTest3loaded or not? If yes then when?