RFR: 8256266: Binding variables don't correct support declaration annotations and the final modifier [v4]

Maurizio Cimadamore mcimadamore at openjdk.java.net
Tue Dec 8 12:47:13 UTC 2020


On Tue, 8 Dec 2020 09:44:23 GMT, Jan Lahoda <jlahoda at openjdk.org> wrote:

>> Basically, javac does not handle code like this properly:
>> 
>> import java.lang.annotation.*;
>> 
>> public class B {
>>      public void test(Object o) {
>>          if (o instanceof @A String s) {}
>>      }
>> }
>> 
>> @Target(ElementType.LOCAL_VARIABLE)
>> @interface A {}
>> 
>> The parser needs to allow declaration annotations on binding variables, see:
>> http://cr.openjdk.java.net/~gbierman/jep394/jep394-20201012/specs/patterns-instanceof-jls.html#jls-14.30.1.1
>
> Jan Lahoda has updated the pull request incrementally with two additional commits since the last revision:
> 
>  - Removing forgotten debug call.
>  - Reject final modifiers on non-pattern matching instanceof.

Changes look good to me

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

Marked as reviewed by mcimadamore (Reviewer).

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


More information about the compiler-dev mailing list