[sealed] Sealed local classes?
forax at univ-mlv.fr
Wed Oct 9 22:13:00 UTC 2019
I agree, PermittedSubtypes should only contains stable names.
----- Mail original -----
> De: "Brian Goetz" <brian.goetz at oracle.com>
> À: "amber-spec-experts" <amber-spec-experts at openjdk.java.net>
> Envoyé: Mercredi 9 Octobre 2019 23:26:26
> Objet: [sealed] Sealed local classes?
> It is allowable, though somewhat silly, to put the `final` modifier on
> local classes.
> From a hierarchy-protection point of view, allowing local classes to be
> `sealed` is also silly, as it cannot be extended from outside the method
> anyway, and even if it could, such types can't show up in APIs that are
> accessible from outside.
> From an exhaustiveness point of view, though, one can imagine having a
> sealed local hierarchy (sum of records) that will be switched over
> within the method, though one would have to work pretty hard to imagine
> Note that a local class cannot be a subtype of a sealed type declared
> outside the same method (*), since it can't be denoted in the permits
> (*) unless the permits clause is inferred. Yuck. Now a mangled name
> would go into the PermittedSubtypes attribute.
> Proposal: ban `sealed` and `non-sealed` modifiers on _local_ classes and
More information about the amber-spec-experts