RFR: 8320144: Compilation crashes when a custom annotation with invalid default value is used [v2]
Jan Lahoda
jlahoda at openjdk.org
Wed Dec 6 08:34:36 UTC 2023
On Tue, 5 Dec 2023 22:04:48 GMT, Aggelos Biboudis <abimpoudis at openjdk.org> wrote:
>> The erroneous case of:
>>
>> `public String[] excludeModules() default new String[0];`
>>
>> was not short-circuited in the compiler and we were getting an NPE in `l.nonEmpty()` for `l`. Now, `getAnnotationArrayValue` returns the error attribute, if that case is detected.
>
> Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision:
>
> Address review
src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Annotate.java line 716:
> 714: ListBuffer<Attribute> buf = new ListBuffer<>();
> 715: for (List<JCExpression> l = na.elems; l.nonEmpty(); l = l.tail) {
> 716: buf.append(attributeAnnotationValue(types.elemtype(expectedElementType),
Here, I would be more inclined to attribute the values even in the erroneous case. Like if someone writes:
public String[] value() default new String[0] {Other.CONSTANT}
Attributing even for the erroneous case would mean the AST would have types/symbols filled in, for possible further use.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/16977#discussion_r1416915879
More information about the compiler-dev
mailing list