Open Sanne opened 4 days ago
Hi, this PR should fix this issue for a lot of cases https://github.com/oracle/graal/pull/10100.
However, some annotation members (arrays, classes or other annotations) still cannot be correctly loaded.
Awesome, thank you! Will test it soon - it might be good enough to keep exploring further.
@Zeavee thanks that looks like progress indeed! However I still can't buid it successfully, it looks like the annotation attributes aren't retaining the right type:
The build process encountered an unexpected error:
com.oracle.svm.core.util.VMError$HostedError: InternalFeature defined by com.oracle.svm.hosted.imagelayer.LayeredDispatchTableSupportFeature unexpectedly failed with a(n) jdk.graal.compiler.debug.GraalError
at org.graalvm.nativeimage.builder/com.oracle.svm.core.util.VMError.shouldNotReachHere(VMError.java:86)
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.FeatureHandler.handleFeatureError(FeatureHandler.java:304)
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.FeatureHandler.forEachFeature(FeatureHandler.java:95)
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.runPointsToAnalysis(NativeImageGenerator.java:808)
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:567)
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.run(NativeImageGenerator.java:533)
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.buildImage(NativeImageGeneratorRunner.java:545)
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.build(NativeImageGeneratorRunner.java:732)
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.start(NativeImageGeneratorRunner.java:151)
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.main(NativeImageGeneratorRunner.java:99)
Caused by: jdk.graal.compiler.debug.GraalError: Error in record 50 (field -1)
at jdk.graal.compiler/jdk.graal.compiler.util.ObjectCopier$Decoder.decode(ObjectCopier.java:555)
at jdk.graal.compiler/jdk.graal.compiler.util.ObjectCopier.decode(ObjectCopier.java:404)
at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.heap.ImageLayerLoader.getAnalysisParsedGraph(ImageLayerLoader.java:848)
at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.meta.AnalysisMethod.lambda$getBaseLayerGraph$0(AnalysisMethod.java:1003)
at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.meta.AnalysisMethod.setGraph(AnalysisMethod.java:1023)
at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.meta.AnalysisMethod.getBaseLayerGraph(AnalysisMethod.java:1003)
at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.meta.AnalysisMethod.ensureGraphParsedHelper(AnalysisMethod.java:977)
at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.meta.AnalysisMethod.ensureGraphParsed(AnalysisMethod.java:958)
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.heap.SVMImageLayerLoader.initializeBaseLayerMethod(SVMImageLayerLoader.java:201)
at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.heap.ImageLayerLoader.initializeBaseLayerMethod(ImageLayerLoader.java:817)
at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.meta.AnalysisUniverse.createMethod(AnalysisUniverse.java:442)
at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.meta.AnalysisUniverse.lookupAllowUnresolved(AnalysisUniverse.java:420)
at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.meta.AnalysisUniverse.lookup(AnalysisUniverse.java:396)
at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.meta.AnalysisType.getOrCalculateOpenTypeWorldDispatchTableMethods(AnalysisType.java:1405)
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.imagelayer.LayeredDispatchTableSupportFeature.beforeAnalysis(LayeredDispatchTableSupport.java:747)
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.lambda$runPointsToAnalysis$0(NativeImageGenerator.java:808)
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.FeatureHandler.forEachFeature(FeatureHandler.java:93)
... 7 more
Caused by: com.oracle.svm.hosted.annotation.AnnotationMetadata$AnnotationExtractionError: Failed to process '@com.oracle.svm.core.annotate.TargetElement(name="", onlyWith="[Ljava.lang.Class;@39a55e10")': java.lang.reflect.InvocationTargetException
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.annotation.AnnotationMemberValue.getMemberValue(AnnotationMemberValue.java:78)
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.annotation.AnnotationValue.lambda$new$0(AnnotationValue.java:90)
at java.base/java.util.HashMap.forEach(HashMap.java:1430)
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.annotation.AnnotationValue.<init>(AnnotationValue.java:89)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:215)
at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:1024)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:570)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:560)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:636)
at java.base/java.util.stream.AbstractPipeline.evaluateToArrayNode(AbstractPipeline.java:291)
at java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:656)
at java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:662)
at java.base/java.util.stream.ReferencePipeline.toList(ReferencePipeline.java:667)
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.annotation.SubstrateAnnotationExtractor.getAnnotationData(SubstrateAnnotationExtractor.java:189)
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.annotation.SubstrateAnnotationExtractor.hasAnnotation(SubstrateAnnotationExtractor.java:149)
at org.graalvm.nativeimage/org.graalvm.nativeimage.AnnotationAccess.isAnnotationPresent(AnnotationAccess.java:82)
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.cenum.CEnumCallWrapperSubstitutionProcessor.lookup(CEnumCallWrapperSubstitutionProcessor.java:54)
at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.infrastructure.SubstitutionProcessor$ChainedSubstitutionProcessor.lookup(SubstitutionProcessor.java:121)
at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.infrastructure.SubstitutionProcessor$ChainedSubstitutionProcessor.lookup(SubstitutionProcessor.java:121)
at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.infrastructure.SubstitutionProcessor$ChainedSubstitutionProcessor.lookup(SubstitutionProcessor.java:121)
at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.meta.AnalysisUniverse.lookupAllowUnresolved(AnalysisUniverse.java:417)
at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.meta.AnalysisUniverse.lookup(AnalysisUniverse.java:396)
at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.heap.ImageLayerLoader.createBaseLayerMethod(ImageLayerLoader.java:777)
at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.heap.ImageLayerLoader.loadMethod(ImageLayerLoader.java:740)
at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.heap.ImageLayerLoader.getAnalysisMethod(ImageLayerLoader.java:783)
at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.heap.ImageLayerSnapshotUtil$AnalysisMethodBuiltIn.decode(ImageLayerSnapshotUtil.java:370)
at jdk.graal.compiler/jdk.graal.compiler.util.ObjectCopier$Decoder.decode(ObjectCopier.java:489)
... 23 more
Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:110)
at java.base/java.lang.reflect.Method.invoke(Method.java:567)
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.annotation.AnnotationMemberValue.getMemberValue(AnnotationMemberValue.java:76)
... 49 more
Caused by: java.lang.ClassCastException: class java.lang.String cannot be cast to class [Ljava.lang.Class; (java.lang.String and [Ljava.lang.Class; are in module java.base of loader 'bootstrap')
at jdk.proxy2/jdk.proxy2.$Proxy36.onlyWith(Unknown Source)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
... 51 more
Describe the Issue
When
ImageLayerLoader#createBaseLayerMethod
is loading the layer's methodData it's defining annotations as well, but these annotations seem lacking their attributes.In some cases not having these values leads to critical failures; for example GraalVM itself makes use of the annotation
com.oracle.svm.core.AlwaysInline
which strictly requires a value for its main attribute. This is used, for example, inTarget_jdk_internal_foreign_SegmentFactories
.The lack of this attribute leads to the annotation being invalid, which in turn results in a critical compilation error:
I do also wonder what other problems are likely going to be caused by this, I believe many of our frameworks would need to read the actual annotation attributes; it seems that the current code would fallback to their default values, which is not correct.
Using the latest version of GraalVM can resolve many issues.
GraalVM Version
Built from
e238132d615da50c4d380c76dbe548caf94e5834
Operating System and Version
Fedora Linux 41
Build Command
Core layer preparation:
Failing build:
Expected Behavior
To be able to use annotations as usual.
Actual Behavior
Failed build
Steps to Reproduce
I hope the description I provided is clear enough as I pointed to the specific code which is problematic.
Additional Context
No response
Build Log Output and Error Messages
No response