Closed ianhash closed 5 months ago
Interesting. I have no idea why this happens, any insights are welcome.
Interesting. I have no idea why this happens, any insights are welcome.
I think there is a circular dependencies in static initialization ,
SQLiteConfig.class -> SQLiteConfig static block -> SQLiteConfig.Pragma -> SQLiteConfig.OnOff -> SQLiteConfig.class
I think the private static field OnOff
needs to be extracted to another class,just like this:
static class OnOff {
private static final String[] OnOff = new String[] { "true", "false" };
}
i tried inlining the OnOff
field and remove the field altogether, but the problem remains.
i tried inlining the
OnOff
field and remove the field altogether, but the problem remains.
inlining MUST BE OK,
public class Foo {
public static final Set<String> FOO_TYPES = new HashSet<>();
private static final String[] OnOff = new String[] { "true", "false" };
static {
for (Foo.FooType v : Foo.FooType.values()) {
FOO_TYPES.add(v.name());
}
}
public static enum FooType {
A(null),
B(OnOff), // BAD
// B(new String[] { "true", "false" }) , // GOOD
;
public final String[] choices;
FooType(String[] onOff) {
this.choices = onOff;
}
}
}
BTW: My suggestion is to extract OnOff
into another class。
inlining MUST BE OK,
i tested this with a unit test and it still fails. I don't see how extracting the class would be any different, if inlining the array does not work.
inlining MUST BE OK,
i tested this with a unit test and it still fails. I don't see how extracting the class would be any different, if inlining the array does not work.
The method toStringArray
has same problem. this method is only called in class Pragma
, so I moved it to Pragma
.
please look into my pr #1124 for the details.
🎉 This issue has been resolved in 3.46.0.1
(Release Notes)
Describe the bug i got java.lang.ExceptionInInitializerError when calling SQLiteConfig.Pragma.values(), it seems there was an issue during the static initialization phase of the Pragma enum in the SQLiteConfig class
To Reproduce
sqlite-jdbc version >=3.25.2,here is 3.46.0.0
Expected behavior just like sqlite-jdbc version <=3.23.1, it should print all SQLiteConfig.Pragma enum contants.
Logs sqlite-jdbc version = 3.46.0.0
Environment (please complete the following information):
adoptopenjdk-8.jdk
openjdk@11/11.0.23
openjdk 21.0.3
oracel jdk-22
Additional context