Repository navigation
Refactor Error Prone bug patterns to use annotation mirrors and AnnotationNames - #6229
Merged
Merged
Conversation
copybara-service
Bot
force-pushed
the
test_975171319
branch
4 times, most recently
from
October 22, 2026 18:09
b9aa241 to
9c1b211
Compare
…ationNames Avoids reflective class-literal-based annotation lookups (`getAnnotation(Class<T>)`) in Error Prone bug patterns by reading `AnnotationMirror` and using `MoreAnnotations` helpers. Replaces duplicate string literal occurrences across bug patterns with `AnnotationNames` constants. Key changes: - `DoNotCallChecker`: updated `getDoNotCallValue` to use `MoreAnnotations.getStringValue(symbol, DO_NOT_CALL_ANNOTATION)`. - `IncompatibleModifiersChecker` & `RequiredModifiersChecker`: updated to use `MoreAnnotations.getEnumValues(symbol, ...)`. - `GuardedByUtils`: updated `getGuardValues` to use `sym.getAnnotationMirrors()` and `MoreAnnotations.getStrings`. - `UnnecessaryAssignment`: updated `isOptionalInject` to use `MoreAnnotations.getBooleanValue`. - `AbstractMockChecker`, `FieldCanBeFinal`, `ThreadSafety`, `AssistedParameters`: migrated to `AnnotationMirror` and `MoreAnnotations.asElement`. - `BadImport`, `DifferentNameButSame`, `NullableOnContainingClass`, `QualifierWithTypeUse`, `InvalidTargetingOnScopingAnnotation`, `RecordComponentAccessorAnnotationConflict`, `NullablePrimitiveArray`, `FieldCanBeLocal`: updated to use `MoreAnnotations.targetsElement` / `MoreAnnotations.getTargetElementTypes` / `MoreAnnotations.isTypeAnnotation`. - `ElementPredicates`, `MissingRuntimeRetention`: updated to use `MoreAnnotations.hasRuntimeRetention` / `MoreAnnotations.getRetentionPolicy` / `ASTHelpers.hasAnnotation`. - `NonOverridingEquals`, `BanClassLoader`: updated to use `ASTHelpers.hasAnnotation` with string literal. - `IncompatibleArgumentType`: updated to use `MoreAnnotations.getStringValue(symbol, ...)`. - `InlineMeData`, `Inliner`: updated to use `MoreAnnotations.getAnnotationWithSimpleName` and `MoreAnnotations.getStrings`. - `RestrictedApiChecker`: updated to use `MoreAnnotations.getTypeValue`, `MoreAnnotations.getTypes`, and `MoreAnnotations.getBooleanValue`. - Replaced annotation string literals with `AnnotationNames` constants across bug patterns. PiperOrigin-RevId: 1004922280
copybara-service
Bot
force-pushed
the
test_975171319
branch
from
October 22, 2026 18:28
9c1b211 to
e5aac42
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Refactor Error Prone bug patterns to use annotation mirrors and AnnotationNames
Avoids reflective class-literal-based annotation lookups (
getAnnotation(Class<T>)) in Error Prone bug patterns by readingAnnotationMirrorand usingMoreAnnotationshelpers.Replaces duplicate string literal occurrences across bug patterns with
AnnotationNamesconstants.Key changes:
DoNotCallChecker: updatedgetDoNotCallValueto useMoreAnnotations.getStringValue(symbol, DO_NOT_CALL_ANNOTATION).IncompatibleModifiersChecker&RequiredModifiersChecker: updated to useMoreAnnotations.getEnumValues(symbol, ...).GuardedByUtils: updatedgetGuardValuesto usesym.getAnnotationMirrors()andMoreAnnotations.getStrings.UnnecessaryAssignment: updatedisOptionalInjectto useMoreAnnotations.getBooleanValue.AbstractMockChecker,FieldCanBeFinal,ThreadSafety,AssistedParameters: migrated toAnnotationMirrorandMoreAnnotations.asElement.BadImport,DifferentNameButSame,NullableOnContainingClass,QualifierWithTypeUse,InvalidTargetingOnScopingAnnotation,RecordComponentAccessorAnnotationConflict,NullablePrimitiveArray,FieldCanBeLocal: updated to useMoreAnnotations.targetsElement/MoreAnnotations.getTargetElementTypes/MoreAnnotations.isTypeAnnotation.ElementPredicates,MissingRuntimeRetention: updated to useMoreAnnotations.hasRuntimeRetention/MoreAnnotations.getRetentionPolicy/ASTHelpers.hasAnnotation.NonOverridingEquals,BanClassLoader: updated to useASTHelpers.hasAnnotationwith string literal.IncompatibleArgumentType: updated to useMoreAnnotations.getStringValue(symbol, ...).InlineMeData,Inliner: updated to useMoreAnnotations.getAnnotationWithSimpleNameandMoreAnnotations.getStrings.RestrictedApiChecker: updated to useMoreAnnotations.getTypeValue,MoreAnnotations.getTypes, andMoreAnnotations.getBooleanValue.AnnotationNamesconstants across bug patterns.