Skip to content

[GR-78020] Use generated wrappers when accessing guest annotations - #14318

Merged
graalvmbot merged 8 commits into
masterfrom
d-kozak/GR-78020/migrate-guest-annotation-consumers
Aug 26, 2026
Merged

[GR-78020] Use generated wrappers when accessing guest annotations#14318
graalvmbot merged 8 commits into
masterfrom
d-kozak/GR-78020/migrate-guest-annotation-consumers

Conversation

@graalvmbot

Copy link
Copy Markdown
Collaborator

Champion reviewer: Josef Eisl

Summary

When Native Image runs with an external JVMCI runtime, annotation data belongs to the guest VM. Build-time code previously converted that data into java.lang.Annotation proxy objects in the builder VM, even when it only needed to check whether an annotation exists or read a few members.

This PR removes those unnecessary builder-side proxies:

  • Presence checks inspect guest annotation data directly.
  • Consumers that read annotation members use AnnotationValue or generated typed *GuestValue records.
  • Repeatable annotations are read as direct and container AnnotationValue entries and then converted through generated wrappers.
  • Generated records read all annotation members when they are created, reporting malformed internal annotations immediately.
  • The obsolete conversion from builder annotation objects back to AnnotationValue is removed.
  • The remaining C-interface callbacks that require builder classes are documented and tracked by GR-78934.

Commit Structure

The eight commits first introduce generated direct-access helpers and convert preexisting ordinary wrapper lookups. The remaining commits separate removal of the reverse conversion, conversion of presence-only checks, adoption of existing generated records, generation of additional records, migration of member-reading consumers, and migration of repeatable annotations.

Scope

This PR migrates all build-time builder-to-guest annotation consumers, including repeatable annotations and their generated container annotations. Five annotation lookups remain in compiler code shared between image building and the Crema or Ristretto runtime compiler paths; they intentionally retain the runtime-aware API.

Three C-interface configuration callbacks still require builder classes. GR-78934 tracks moving those callbacks into the guest context and removing the remaining class-conversion boundaries.

Generate a hosted-only get method on each guest annotation value that combines metadata lookup with conversion to the generated record. Retain the from method for consumers that already hold raw annotation metadata, such as declared-only and repeatable lookups.
Replace the ordinary generated-value lookup patterns that predate this migration with the generated get shorthand. Keep raw from conversions only where callers intentionally process declared-only or nested annotation metadata.
Retain injected substitution annotations as AnnotationValue metadata and remove unused constructors that accepted materialized annotations. Remove the now-dead reverse conversion APIs so builder-to-guest annotation flow remains metadata-native.
Replace builder annotation materialization used only for null checks with GuestAnnotationAccess.isAnnotationPresent. This keeps presence queries in metadata form across hosted, compiler, Truffle, interpreter, and Web Image consumers.
Use the existing C entry-point and C-function guest value records instead of materializing builder annotations. Keep class-valued members as ResolvedJavaType metadata and invoke entry-point predicates in the guest context.
Register generated metadata wrappers for the remaining hosted guest annotation consumers. Place each wrapper family in a shared package for its consuming module and enable the processor where needed.
Replace the remaining hosted builder annotation materialization with generated metadata records. Keep class-valued members as guest types where consumers can operate on metadata and preserve narrow host-class conversion boundaries only for legacy callback APIs tracked by GR-78934.

Resolve hosted policy types directly through guest metadata, remove obsolete annotation-taking code paths, and retain only the annotation processors required to generate the migrated values.
Replace builder annotation materialization for the four repeatable consumers with a metadata-level lookup that preserves direct-first, container-second ordering.

Generate typed wrappers for the repeated leaf annotations and keep class-valued comparisons in the guest context.
@oracle-contributor-agreement oracle-contributor-agreement Bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Aug 26, 2026
@graalvmbot
graalvmbot merged commit 338966b into master Aug 26, 2026
3 checks passed
@graalvmbot
graalvmbot deleted the d-kozak/GR-78020/migrate-guest-annotation-consumers branch August 26, 2026 22:56
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