Open
Description
Description of the issue
The elements of annotation interfaces can have default values, for example:
@interface MyInterface {
String value() default "test";
}
However, currently AnnotationElement
does not provide any predicates for detecting such default values. It appears they do not even exist in the database unless an annotation of the declaring annotation type is used somewhere. And even then they only exist as expression without source location.
(Note that the Annotation
predicates always include the default values in their results.)
It would be good to add the following predicates
predicate hasDefaultValue()
Note that the predicateisDefault()
does not work for this because an annotation element with default value is not adefault
method, in fact it is an abstract method with theAnnotationDefault
attribute in bytecode (see JVM spec 16 §4.7.22).Expr getDefaultValue()
Note that even though anAnnotationElement
is effectively a method (see Java: AnnotationElement does not extend Method #5399), the default value should probably not be modeled as result of a syntheticreturn
in the method body, but be stored directly in the database. As pointed out above, an annotation element with default value is not a regulardefault
method, therefore modeling it as such would be irritating (e.g. it would have to be modeled asabstract
method whosegetBody()
has a result).
Ideally this predicate would also work for annotations declared in third party code, not being part of the source, in case that is possible.