Open TruthBean opened 2 years ago
solution:
change org.apache.ibatis.type.JdbcType.codeLookup
to delayed filling
private final static Map<Integer,JdbcType> codeLookup = new HashMap<>();
JdbcType(int code) {
this.TYPE_CODE = code;
}
public static JdbcType forCode(int code) {
if (codeLookup.isEmpty()) {
for (JdbcType type : JdbcType.values()) {
codeLookup.put(type.TYPE_CODE, type);
}
}
return codeLookup.get(code);
}
Mybatis provides support for different modules in both Spring Native and Quarkus, and I don't think the corresponding GraalVM json file should be added to mybatis itself.
MyBatis version
3.5.9
Database vendor and version
mysql 5.7
Test case or example project
Steps to reproduce
build with gralde
Expected result
build success
Actual result
com.oracle.svm.core.util.UserError$UserException: Classes that should be initialized at run time got initialized during image building: org.apache.ibatis.type.JdbcType was unintentionally initialized at build time. org.apache.ibatis.type.JdbcType caused initialization of this class with the following trace: at org.apache.ibatis.type.JdbcType.(JdbcType.java:30)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Unknown Source)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:568)
at java.lang.Class.getEnumConstantsShared(Class.java:3837)
at java.lang.Class.enumConstantDirectory(Class.java:3859)
at java.lang.Enum.valueOf(Enum.java:267)
at sun.reflect.annotation.AnnotationParser.parseEnumValue(AnnotationParser.java:479)
at sun.reflect.annotation.AnnotationParser.parseMemberValue(AnnotationParser.java:344)
at java.lang.reflect.Method.getDefaultValue(Method.java:717)
at sun.reflect.annotation.AnnotationType.(AnnotationType.java:133)
at sun.reflect.annotation.AnnotationType.getInstance(AnnotationType.java:85)
at com.oracle.svm.core.code.MethodMetadataEncoder.prepareMetadataForClass(MethodMetadataEncoder.java:107)
at com.oracle.svm.core.code.CodeInfoEncoder.prepareMetadataForClass(CodeInfoEncoder.java:240)
at com.oracle.svm.hosted.image.NativeImageCodeCache.buildRuntimeMetadata(NativeImageCodeCache.java:230)
at com.oracle.svm.hosted.image.LIRNativeImageCodeCache.layoutMethods(LIRNativeImageCodeCache.java:106)
at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:608)
at com.oracle.svm.hosted.NativeImageGenerator.run(NativeImageGenerator.java:488)
at com.oracle.svm.hosted.NativeImageGeneratorRunner.buildImage(NativeImageGeneratorRunner.java:403)
at com.oracle.svm.hosted.NativeImageGeneratorRunner.build(NativeImageGeneratorRunner.java:569)
at com.oracle.svm.hosted.NativeImageGeneratorRunner.main(NativeImageGeneratorRunner.java:122)
at com.oracle.svm.hosted.NativeImageGeneratorRunner$JDK9Plus.main(NativeImageGeneratorRunner.java:599)
at com.oracle.svm.core.util.UserError.abort(UserError.java:73) at com.oracle.svm.hosted.classinitialization.ConfigurableClassInitialization.checkDelayedInitialization(ConfigurableClassInitialization.java:555) at com.oracle.svm.hosted.classinitialization.ClassInitializationFeature.afterImageWrite(ClassInitializationFeature.java:316) at com.oracle.svm.hosted.NativeImageGenerator.lambda$doRun$8(NativeImageGenerator.java:663) at com.oracle.svm.hosted.FeatureHandler.forEachFeature(FeatureHandler.java:73) at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:663) at com.oracle.svm.hosted.NativeImageGenerator.run(NativeImageGenerator.java:488) at com.oracle.svm.hosted.NativeImageGeneratorRunner.buildImage(NativeImageGeneratorRunner.java:403) at com.oracle.svm.hosted.NativeImageGeneratorRunner.build(NativeImageGeneratorRunner.java:569) at com.oracle.svm.hosted.NativeImageGeneratorRunner.main(NativeImageGeneratorRunner.java:122) at com.oracle.svm.hosted.NativeImageGeneratorRunner$JDK9Plus.main(NativeImageGeneratorRunner.java:599)