I have a code which initializes a class as:
private static MyClass myObj = new MyClass();
And I am using myObj
in my code below. This works fine if Java 6 is used. But when I use Java 7, NullPointerException
is thrown.
java.lang.NullPointerException
Exception in thread "main" java.lang.ExceptionInInitializerError
As a work around, I put a null check for myObj
before using it and made it work.
But I am still confused if there is any changes in Java 7 implementation that made static initialization fail?
EDIT : Found similar issue was faced by OpenAM.