RFR: JDK14-8236005: local records shouldn't capture any non-static state from any enclosing type

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Fri Jan 10 19:06:30 UTC 2020

Not 100% sure - shouldn't the "staticOnly" variable be set to true when 
we are inside a local record, so that the existing check will issue an 

I see that "staticOnly" is set in this routine:

     /** An environment is "static" if its static level is greater than
      *  the one of its outer environment
     protected static boolean isStatic(Env<AttrContext> env) {
         return env.outer != null && env.info.staticLevel > 

Which makes me think that, maybe the staticLevel of the local record has 
not increased its value as expected?


On 10/01/2020 03:54, Vicente Romero wrote:
> Hi,
> Please review the fix for [1] at [2]. This fix is for the compiler to 
> emit an error if a local record accesses non-static state from the 
> enclosing environment
> Thanks,
> Vicente
> [1] https://bugs.openjdk.java.net/browse/JDK-8236005
> [2] http://cr.openjdk.java.net/~vromero/8236005/webrev.00/

More information about the compiler-dev mailing list