I have a class defined like this:
class MyClass {
private static final String name = "<some string>";
private static final String schema = "{<some json here>}";
public static final MySchemaObject schemaObj = MyUtils.staticSchema(name, schema); // Line1
public static MySchemaObject getStaticSchema() {
return schemaObj;
}
}
Another class calls this class in a static initializer:
class AnotherClass {
private static final MySchemaObject schemaObject = MyClass.getStaticSchema(); <===== Always null
........
}
In the class AnotherClass, the static variable schemaObject is always initialzied into null. This indicates that the Line1 in MyClass is not called by the time the method getStaticSchema is called.
My understanding is that static variable are created before any static method can be called, but it seems not the case.
Can someone please help me understand this?
EDIT: MyUtils.staticSchema will never retur null;
MyClassis not called by the time the methodgetStaticSchemais called." or that it isMyUtils.staticSchemathat simply returns null.