[GR-70940] Replace AnnotatedElement usages with AnnotatedValueSupport in SVM. #12424
+758
−556
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.
As a pre-requisite of GR-69713, this PR replaces usages of
AnnotatedElementmethods in SVM where the receiver is a JVMCI type with methods in the newcom.oracle.svm.util.AnnotationUtilclass which is likeAnnotationAccessbut is for use by SVM internal code. It avoids relying on JVMCI types (such asResolvedJavaType) implementingjava.lang.reflect.AnnotatedElement. This inheritance is planned for removal (GR-69713).These changes were assisted by IntelliJ's support for structural replacement (
Edit->Find->Replace Structurally...).Automated PR Summary
This PR is a preparatory refactor to decouple annotation access in SVM and replace usages of
java.lang.reflect.AnnotatedElementwith a new approach usingAnnotationValueSupportand a utility interfaceAnnotationUtil.Access. The change avoids relying on JVMCI types such asResolvedJavaTypeimplementingAnnotatedElement, supporting the planned removal of this inheritance (as part of GR-69713). In addition, the PR updates and extends SVM annotation-related utilities as well as refactors several internal and testing classes throughout SVM and Espresso to use the new approach. This enables removing a tight coupling with Java reflection and lays the foundation for future refactorings.Key Changes:
com.oracle.svm.util.AnnotationUtilutility class for annotation access, providing access to annotation values without requiring JVMCI types to implementAnnotatedElement.Meta,Field,Klass,ParserMethod,HostedMethod, several Feature and Substitution classes, and infrastructure utilities) to leverageAnnotationUtilover raw reflection.AnnotationAccessfor annotation checks to the new utility across the codebase.