RFR: 8036019: Insufficient alternatives listed in some errors produced by the parser

Aggelos Biboudis duke at openjdk.java.net
Wed Jan 19 17:31:31 UTC 2022


On Wed, 19 Jan 2022 17:08:07 GMT, Aggelos Biboudis <duke at openjdk.java.net> wrote:

>> src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java line 3382:
>> 
>>> 3380:                 }
>>> 3381:             }
>>> 3382:             accept(RBRACE, tk -> Errors.AnnotationMissingElementValue);
>> 
>> I think that this method needs some more massage, annotations like this one are being accepted:
>> 
>> 
>> @SuppressWarnings({,})
>> 
>> even previous to your patch, if my reading of the spec is correct, there should be at least one `ElementValue`
>
> Indeed, that was my observation as well but then I noticed this: 
> 
> https://bugs.openjdk.java.net/browse/JDK-8012722
> 
> This is among the positive tests of that contribution, which exists on master:
> 
> 
> public class SingleCommaAnnotationValue {
>     @Foo({}) void a() { }
>     @Foo({,}) void b() { }
>     @Foo({0}) void c() { }
>     @Foo({0,}) void d() { }
>     @Foo({0,0}) void e() { }
>     @Foo({0,0,}) void f() { }
> }
> @interface Foo { int[] value(); }
> 
> 
> What do you think?

To my understanding the following rule permits `{,}`:


ElementValueArrayInitializer:
   { [ElementValueList] [,] }
ElementValueList:
   ElementValue {, ElementValue}

-------------

PR: https://git.openjdk.java.net/jdk/pull/7019


More information about the compiler-dev mailing list