Skip to content

Conversation

@graalvmbot
Copy link
Collaborator

@graalvmbot graalvmbot commented Oct 21, 2025

This PR replaces usages of AnnotatedElement methods in the Graal compiler with methods in AnnotationValueSupport. This was mostly done with IntelliJ's support for structural replacement (Edit -> Find -> Replace Structurally...).

Inherent in this change is the switch to using AnnotationValue objects instead of Annotation objects. 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 the AnnotationValueParser but still return Annotation objects. This would involve moving com.oracle.svm.hosted.annotation.SubstrateAnnotationExtractor#toAnnotation to AnnotationValueSupport. However, that means we'd need to export java.base/sun.reflect.annotation to jdk.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:

  • Replaces usages of AnnotatedElement methods in the compiler with AnnotationValueSupport methods, as a prerequisite for GR-69713. All annotation lookups now rely on the new abstraction over annotation parsing and values.
  • Migrates all annotation work in the Graal compiler to use AnnotationValue (and associated APIs), instead of Java reflection-based Annotation objects, ensuring proper separation and native-image compatibility.
  • Implements a new verifier test (VerifyAnnotatedElementUsage) to ensure direct calls to AnnotatedElement methods on JVMCI types no longer occur within the compiler.
  • Updates various method and field annotation lookups throughout Graal and its test infrastructure (e.g., plugin registration, snippet handling, bridge method annotation logic) to use the new AnnotationValueSupport methods.
  • Refactors the annotation cache strategy and adds logic to support caching of resolved annotation types in a native-image-compatible way.
  • Updates bridge method annotation utilities to properly forward annotation lookups through AnnotationValueSupport.
  • Extends and updates the AnnotationValue API to support strongly-typed element value extraction, including enums and primitives.
  • Updates related JVMCI and test classes to ensure they now use the new annotations infrastructure.
  • Adds more robust caching and lookups for resolved annotation types and annotation values.
  • Adds a build-time-only test (VerifyAnnotatedElementUsage) to fail if banned usages are reintroduced going forward.
  • Performs minor cleanups and clarifies JavaDoc and usage for the new annotation mechanisms.

@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Oct 21, 2025
@graalvmbot graalvmbot force-pushed the ds/GR-70912 branch 6 times, most recently from a3d1022 to 1bc1e29 Compare October 21, 2025 21:49
…er on a non-supported platform before failing
@graalvmbot graalvmbot force-pushed the ds/GR-70912 branch 3 times, most recently from 23a82ac to 396003a Compare October 23, 2025 19:59
@graalvmbot graalvmbot merged commit 82518e3 into master Oct 24, 2025
13 checks passed
@graalvmbot graalvmbot deleted the ds/GR-70912 branch October 24, 2025 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

OCA Verified All contributors have signed the Oracle Contributor Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants