public class Config {
public static Ref<Config> s = new Ref<Config>(new Config());
static class Ref<T> {
public T r;
public Ref(T r) {
this.r = r;
}
}
public int INTERVAL = 4000;
public Config()
{
}
public static void main(String[] args) {
System.err.println(Config.s.r.INTERVAL);
}
}
Running this cause to java.lang.VerifyError
Exception in thread "main" java.lang.VerifyError: (class: Config, method: main signature: ([Ljava/lang/String;)V) Incompatible type for getting or setting field
If i run this:
System.err.println(Config.s.r);
Than no exception is thrown and in debug i can see the value of 'Config.s.r.INTERVAL'
When i run with -verbose:class i can see that Ref class is not loaded in the first example. In the second example the Ref class is loaded.
This is the only class in the project compiled and run with java6. The problem is not in the jvm or 3rd party.
i guess that the problem is combine in the same line static variable initialization and instance variable.
running like this - work:
Config c = Config.s.r;
System.err.println(c.INTERVAL);
Ps. The code is much complicated and it separated to 2 classes in dev env. I just limit it to short example
Jdk - Java SE 6 [1.6.0_65-b14-462] OS - Mac