RFR: JDK-8235778: No compilation error reported when a record is declared in a local class

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Thu Dec 12 00:08:34 UTC 2019


If sym.isLocal() returns true, is this check

&& (sym.owner.flags_field & STATIC) == 0)

Needed? Aren't we inside a record declaration that is contained in some 
local context (e.g. within a method body), whose immediate enclosing 
type is a type T? If so, isn't T always non-static? I guess yes, unless 
T is a record itself, like:

void m() {
    record A() {
         record B() { }
    }
}

The patch seems to be biased in favor of this - is it deliberate? (also 
there's no test around that). Should the spec say something?

Maurizio

On 11/12/2019 23:39, Vicente Romero wrote:
> Hi,
>
> Please review the fix for [1] at [2]. Records are not allowed to be 
> defined inside inner classes. This patch extends the check to local 
> inner classes which was missing.
>
> Thanks,
> Vicente
>
> https://bugs.openjdk.java.net/browse/JDK-8235778
> http://cr.openjdk.java.net/~vromero/8235778/webrev.00/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20191212/41ae5653/attachment.htm>


More information about the compiler-dev mailing list