Repository navigation
Closed
Labels
Description
In Spring Boot we use this idiom a lot:
...
@Configuration
@Import({ JacksonHttpMessageConvertersConfiguration.class,
GsonHttpMessageConvertersConfiguration.class,
JsonbHttpMessageConvertersConfiguration.class })
public class HttpMessageConvertersAutoConfiguration {
...
}and then
@Configuration
@ConditionalOnClass(Jsonb.class)
class JsonbHttpMessageConvertersConfiguration {
...
}where Jsonb.class is often not available at runtime,
The @Import references classes whose annotations might not be inspectable at runtime, but since we never actually try to do that, it should be fine. In fact, typically, at most one of those 3 will be available (sometimes none). GraalVM barfs on this:
$ native-image -Dio.netty.noUnsafe=true -H:Name=target/mini -H:ReflectionConfigurationFiles=mini.json --report-unsupported-elements-at-runtime -cp $CP com.example.mini.MiniApplication --debug-attach=8000
Listening for transport dt_socket at address: 8000
classlist: 8,484.46 ms
(cap): 1,235.46 ms
setup: 4,201.41 ms
analysis: 205,917.07 ms
fatal error: java.lang.ArrayStoreException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at java.util.concurrent.ForkJoinTask.getThrowableException(ForkJoinTask.java:598)
at java.util.concurrent.ForkJoinTask.get(ForkJoinTask.java:1005)
at com.oracle.svm.hosted.NativeImageGenerator.run(NativeImageGenerator.java:414)
at com.oracle.svm.hosted.NativeImageGeneratorRunner.buildImage(NativeImageGeneratorRunner.java:275)
at com.oracle.svm.hosted.NativeImageGeneratorRunner.build(NativeImageGeneratorRunner.java:372)
at com.oracle.svm.hosted.NativeImageGeneratorRunner.main(NativeImageGeneratorRunner.java:104)
Caused by: java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy
at sun.reflect.annotation.AnnotationParser.parseClassArray(AnnotationParser.java:724)
at sun.reflect.annotation.AnnotationParser.parseArray(AnnotationParser.java:531)
at sun.reflect.annotation.AnnotationParser.parseMemberValue(AnnotationParser.java:355)
at sun.reflect.annotation.AnnotationParser.parseAnnotation2(AnnotationParser.java:286)
at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:120)
at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:72)
at java.lang.Class.createAnnotationData(Class.java:3521)
at java.lang.Class.annotationData(Class.java:3510)
at java.lang.Class.getAnnotation(Class.java:3415)
at jdk.vm.ci.hotspot.HotSpotResolvedObjectTypeImpl.getAnnotation(HotSpotResolvedObjectTypeImpl.java:800)
at com.oracle.svm.hosted.SVMHost.platformSupported(SVMHost.java:147)
at com.oracle.graal.pointsto.meta.AnalysisUniverse.createType(AnalysisUniverse.java:201)
at com.oracle.graal.pointsto.meta.AnalysisUniverse.lookupAllowUnresolved(AnalysisUniverse.java:193)
at com.oracle.graal.pointsto.meta.AnalysisUniverse.lookup(AnalysisUniverse.java:170)
at com.oracle.graal.pointsto.meta.AnalysisUniverse.lookup(AnalysisUniverse.java:69)
at com.oracle.graal.pointsto.infrastructure.UniverseMetaAccess.lookupJavaType0(UniverseMetaAccess.java:91)
at com.oracle.graal.pointsto.infrastructure.UniverseMetaAccess.lookupJavaType(UniverseMetaAccess.java:82)
at com.oracle.graal.pointsto.meta.AnalysisMetaAccess.lookupJavaType(AnalysisMetaAccess.java:45)
at com.oracle.svm.hosted.ameta.HostedDynamicHubFeature.replace(HostedDynamicHubFeature.java:54)
at com.oracle.graal.pointsto.meta.AnalysisUniverse.replaceObject(AnalysisUniverse.java:521)
at com.oracle.graal.pointsto.ObjectScanner.scanArray(ObjectScanner.java:195)
at com.oracle.graal.pointsto.ObjectScanner.doScan(ObjectScanner.java:276)
at com.oracle.graal.pointsto.ObjectScanner.finish(ObjectScanner.java:312)
at com.oracle.graal.pointsto.ObjectScanner.scanBootImageHeapRoots(ObjectScanner.java:81)
at com.oracle.graal.pointsto.ObjectScanner.scanBootImageHeapRoots(ObjectScanner.java:63)
at com.oracle.graal.pointsto.BigBang.checkObjectGraph(BigBang.java:585)
at com.oracle.graal.pointsto.BigBang.finish(BigBang.java:556)
at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:674)
at com.oracle.svm.hosted.NativeImageGenerator.lambda$run$0(NativeImageGenerator.java:397)
at java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1386)
at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
Error: Image building with exit status 1
The classes and instructions for how to build the jar and the classpath are in the usual place: https://github.com/dsyer/spring-boot-micro-apps/tree/func.
Activity
[-]Native image generator ought to be able to ignore type errors from unloadable annotations[/-][+]Native image generator ought to be able to ignore type errors from unloadable annotation attributes[/+]cstancu commentedon Aug 7, 2018
For reference, we have seen this kind of error in micronaut. See: #470 (comment). The proposed solution is: #470 (comment).
sdeleuze commentedon Sep 25, 2018
I am currently blocked in Spring Fu due to this issue, just doing
ReactiveWebServerFactoryAutoConfiguration configuration = new ReactiveWebServerFactoryAutoConfiguration();fails with the exception reported by @dsyer .cstancu commentedon Sep 25, 2018
@sdeleuze we are working on a major refactoring of the logic that deals with incomplete class paths.
graemerocher commentedon Oct 23, 2018
@cstancu it looks like this is an issue for Micronaut users now too with the addition of the processing of
META-INF/servicesfiles automatically. Previous we could exclude some services to workaround this issue by manually generating thereflect.jsonnow theseMETA-INF/servicesfiles are automatically added due to 84dcb4e#diff-94f52964cecab0a25ac57a96aa80b97aR55Is there a way to disable the logic for
META-INF/servicesfiles? If not can this be resolved, otherwise Micronaut users are hitting this problem with RC8:See micronaut-projects/micronaut-core#766
cstancu commentedon Oct 23, 2018
The automatic registration of services can be disabled with the
-H:-UseServiceLoaderFeatureoption. Then you can fallback to your customMETA-INF/servicesprocessing.GraalVM-rc.8 compatibility
cstancu commentedon Feb 8, 2019
This issue should be fixed as of RC12.