clarity needed for the non-sealed keyword

Vicente Romero vicente.romero at oracle.com
Wed Oct 7 12:47:15 UTC 2020


Hi,

this is correct, non-sealed is a contextual keyword, meaning that 
depending on the context it is treated as a keyword or not. So in the 
test case below it is not treated as a keyword as it is not used in a 
class or interface definition. The concept of contextual keywords is 
currently being formalized you can check the last version of the spec 
here [1]

Thanks,
Vicente

[1] 
http://cr.openjdk.java.net/~dlsmith/8245310/8245310-20200918/specs/contextual-keywords-jls.html

On 10/7/20 2:25 AM, Pravin Jain wrote:
> Dear sir,
>
> consider the following code.
> public class TestKeyword {
>      int non = 7;
>      int sealed = 5;
>      int a = non-sealed; // non-sealed not identified as keyword here,
> }
>
> In suggested changes to Chapter 3 of the JLS, it does not clarify that
> non-sealed will not be tokenized as keyword inside the body of a type
> declaration, and I am assumpting that non-sealed classes would not be
> allowed inside a type as nested type or local classes.
> If in future It is going to be allowed as local class or nested class,
> then it may be better to avoid '-' inside a keyword.
>
> I feel clarity is missing on this in the suggested changes to the JLS.
>
> Thanks and regards,
> Pravin
>
>
> --
> Pravin Jain
> (M)+91-9426054269



More information about the amber-dev mailing list