ArC: filter out class-retained or missing annotations #29452
Merged
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.
Sometimes, ArC used to call the
AnnotationLiteralProcessor
with annotations that are either class-retained, or their classes are missing (which is perfectly legal). It is a minority of callers though -- most of them only callAnnotationLiteralProcessor
with qualifiers or interceptor bindings. Those must always be runtime-retained and their classes must be present, and it is an error if they are not.At the same time, we don't want to generate annotation literals for class-retained annotations or for annotations whose classes are missing.
The
AnnotationLiteralProcessor
already checks that the annotation class exists, so with this commit, it also checks that the annotation for which the literal is generated is runtime-retained. If not, an exception is thrown. This lets us know that there's a problem somewhere.There are 2 places where ArC deals with arbitrary annotations and may need to generate annotation literals for them; in both cases, the code has to process all annotations present on an injection point. In these cases, it is straightforward to filter out class-retained annotations and missing annotation classes.
Fixes #29425