clarity needed for the non-sealed keyword
Remi Forax
forax at univ-mlv.fr
Wed Oct 7 12:53:12 UTC 2020
Hi Pravin,
a sealed type lists all it's subtypes (the permits clause) so the name of a subtype have to be stable, i.e. not change from one compilation to an other or from one compiler to an other.
So you can not use a local class as a subtype of a sealed type because the name of a local class is not stable.
So there is no ambiguity for the tokens "non-sealed" inside a method, it always means "non" "-" "sealed".
Rémi
----- Mail original -----
> De: "Pravin Jain" <pravin at zensoftech.co.in>
> À: "amber-dev" <amber-dev at openjdk.java.net>
> Envoyé: Mercredi 7 Octobre 2020 08:25:14
> Objet: clarity needed for the non-sealed keyword
> 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