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 reason in 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 debugging I can see the value "Config.srINTERVAL"
When I run with -verbose: class, I see that the Ref class is not loaded in the first example. In the second example, the class Ref is loaded.
This is the only project class compiled and launched using java6. The problem is not with jvm or a third party.
I assume the problem is combined in the same initialization of a static string variable and an instance variable.
works as follows - work:
Config c = Config.s.r;
System.err.println(c.INTERVAL);
Ps. The code is very complex and it is divided into 2 classes in dev env. I just limit it to a short example
Jdk - Java SE 6 [1.6.0_65-b14-462] OS - Mac