[GR-70912] Replace AnnotatedElement usages with AnnotatedValueSupport in the compiler. #12406
+627
−122
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR replaces usages of
AnnotatedElementmethods in the Graal compiler with methods inAnnotationValueSupport. This was mostly done with IntelliJ's support for structural replacement (Edit->Find->Replace Structurally...).Inherent in this change is the switch to using
AnnotationValueobjects instead ofAnnotationobjects. Given that all uses of annotations in the compiler are only in a context where full reflection is supported (e.g. jargraal), it would be possible to use theAnnotationValueParserbut still returnAnnotationobjects. This would involve movingcom.oracle.svm.hosted.annotation.SubstrateAnnotationExtractor#toAnnotationtoAnnotationValueSupport. However, that means we'd need to exportjava.base/sun.reflect.annotationtojdk.graal.compiler(complicating all jargraal-like launchers). I don't think that's worth it given the limited use of annotations in the compiler.Automated PR Summary
[Summary of the PR]
Key Changes:
AnnotatedElementmethods in the compiler withAnnotationValueSupportmethods, as a prerequisite for GR-69713. All annotation lookups now rely on the new abstraction over annotation parsing and values.AnnotationValue(and associated APIs), instead of Java reflection-basedAnnotationobjects, ensuring proper separation and native-image compatibility.VerifyAnnotatedElementUsage) to ensure direct calls toAnnotatedElementmethods on JVMCI types no longer occur within the compiler.AnnotationValueSupportmethods.AnnotationValueSupport.AnnotationValueAPI to support strongly-typed element value extraction, including enums and primitives.VerifyAnnotatedElementUsage) to fail if banned usages are reintroduced going forward.