It seems that the compiler is inserting a reference to the string literal "foo" , so the JRE does not actually load Test6 to get it.
If you make changes, for example:
public static final String FOO = new String("foo");
then the Test6 class Test6 loaded (and its static block is executed).
source share