@@ -59,27 +59,23 @@ class RetentionAnnotation extends Annotation {
59
59
RetentionAnnotation ( ) { this .getType ( ) .hasQualifiedName ( "java.lang.annotation" , "Retention" ) }
60
60
61
61
/**
62
+ * DEPRECATED: Getting the field access expression is rarely useful. Use `getRetentionPolicy()`
63
+ * to get the name of the retention policy.
64
+ *
62
65
* Gets the retention policy expression within this annotation.
63
66
*
64
67
* For example, the field access `RetentionPolicy.RUNTIME` is the
65
68
* retention policy expression in `@Retention(RetentionPolicy.RUNTIME)`.
66
69
*/
67
- Expr getRetentionPolicyExpression ( ) { result = this .getValue ( "value" ) }
70
+ deprecated Expr getRetentionPolicyExpression ( ) { result = this .getValue ( "value" ) }
68
71
69
72
/**
70
73
* Gets the name of the retention policy of this annotation.
71
74
*
72
75
* For example, `RUNTIME` is the name of the retention policy
73
76
* in `@Retention(RetentionPolicy.RUNTIME)`.
74
77
*/
75
- string getRetentionPolicy ( ) {
76
- exists ( EnumConstant ec |
77
- ec = this .getRetentionPolicyExpression ( ) .( FieldRead ) .getField ( ) and
78
- ec .getDeclaringType ( ) .hasQualifiedName ( "java.lang.annotation" , "RetentionPolicy" )
79
- |
80
- result = ec .getName ( )
81
- )
82
- }
78
+ string getRetentionPolicy ( ) { result = this .getEnumConstantValue ( "value" ) .getName ( ) }
83
79
}
84
80
85
81
/** A `@Repeatable` annotation. */
@@ -122,11 +118,7 @@ abstract class NonReflectiveAnnotation extends Annotation { }
122
118
123
119
library class StandardNonReflectiveAnnotation extends NonReflectiveAnnotation {
124
120
StandardNonReflectiveAnnotation ( ) {
125
- exists ( AnnotationType anntp | anntp = this .getType ( ) |
126
- anntp .hasQualifiedName ( "java.lang" , "Override" ) or
127
- anntp .hasQualifiedName ( "java.lang" , "Deprecated" ) or
128
- anntp .hasQualifiedName ( "java.lang" , "SuppressWarnings" ) or
129
- anntp .hasQualifiedName ( "java.lang" , "SafeVarargs" )
130
- )
121
+ this .getType ( )
122
+ .hasQualifiedName ( "java.lang" , [ "Override" , "Deprecated" , "SuppressWarnings" , "SafeVarargs" ] )
131
123
}
132
124
}
0 commit comments