The problem is that Aa is a variable.
A variable of primitive type or String type, which is final and initialized by the expression of the compile-time constant (ยง15.28), is called a constant variable.
Therefore, your Manager.main method Manager.main compiled as if it were:
public static void main(String ...arg) { System.out.println("main"); System.out.println(9); }
There is no real reference to Aa , so class A should not even exist, not to mention initialization. (You can remove A.class and still run Manager .)
If you rely on using Aa to make sure the type is initialized, you should not add the no-op method instead:
public static void ensureClassIsInitialized() { }
then just call it from your main method. This is very unusual, but you need to do it.
source share