Class modifiers in Java 16
forax at univ-mlv.fr
forax at univ-mlv.fr
Thu May 27 19:29:28 UTC 2021
> De: "Brian Goetz" <brian.goetz at oracle.com>
> À: "Remi Forax" <forax at univ-mlv.fr>
> Cc: "Tagir Valeev" <amaembo at gmail.com>, "compiler-dev"
> <compiler-dev at openjdk.java.net>, "amber-dev" <amber-dev at openjdk.java.net>
> Envoyé: Jeudi 27 Mai 2021 15:37:11
> Objet: Re: Class modifiers in Java 16
> I think there’s a bit of preparing for the future here. There’s the concepts
> (how static interacts with nesting) which is separate from which exact
> combinations of those concepts that the language currently supports. We’re
> moving towards trying to get rid of the arbitrary nest-x-in-y rules, step 1 was
> defining the concepts separate from the arbitrary restrictions, but we haven’t
> lifted the restrictions yet.
BTW, why annotations are not allowed in any nested context local or not ?
It's a PITA when writing unit tests, the annotations have always a scope too broad.
Rémi
>> On May 27, 2021, at 9:32 AM, Remi Forax < [ mailto:forax at univ-mlv.fr |
>> forax at univ-mlv.fr ] > wrote:
>> ----- Mail original -----
>>> De: "Tagir Valeev" < [ mailto:amaembo at gmail.com | amaembo at gmail.com ] >
>>> À: "compiler-dev" < [ mailto:compiler-dev at openjdk.java.net |
>>> compiler-dev at openjdk.java.net ] >, "amber-dev" < [
>>> mailto:amber-dev at openjdk.java.net | amber-dev at openjdk.java.net ] >
>>> Envoyé: Jeudi 27 Mai 2021 12:22:48
>>> Objet: Class modifiers in Java 16
>>> Hello!
>>> I want to clarify my understanding of Java 16 spec and the
>>> corresponding compiler behavior regarding class modifiers (8.1.1)
>>> 1. static modifier
>>> Java 15 spec 8.1.1 [1] says:
>>> The modifier static pertains only to member classes (§8.5.1), not to
>>> top level or local or anonymous classes.
>>> Java 16 spec 8.1.1 [2] says:
>>> The modifier static pertains only to member classes and local classes.
>>> However, Java 16 spec 14.3 says:
>>> It is a compile-time error if a local class or interface declaration
>>> has the modifier static (§8.1.1).
>>> Is it my bad understanding of English or there's some contradiction?
>>> To me, 8.1.1 says that now, local classes can be declared as static
>>> while 14.3 says the opposite thing.
>> In JEP 395, under "Static members of inner classes"
>> "We relax this restriction in order to allow an inner class to declare members
>> that are either explicitly or implicitly static. In particular, this allows an
>> inner class to declare a static member that is a record class."
>> that why 8.1.1 was modified.
>> Yes, the sentence in 14.3 seems wrong.
>>> Thank you in advance,
>>> With best regards,
>>> Tagir Valeev.
>> regards,
>> Rémi
>>> [1]
>>> [
>>> https://docs.oracle.com/javase/specs/jls/se15/html/jls-8.html#jls-ClassModifier
>>> |
>>> https://docs.oracle.com/javase/specs/jls/se15/html/jls-8.html#jls-ClassModifier
>>> ]
>>> [2]
>>> [
>>> https://docs.oracle.com/javase/specs/jls/se16/html/jls-8.html#jls-ClassModifier
>>> |
>>> https://docs.oracle.com/javase/specs/jls/se16/html/jls-8.html#jls-ClassModifier
>>> ]
>>> [3] [ https://docs.oracle.com/javase/specs/jls/se16/html/jls-14.html#jls-14.3 |
>>> https://docs.oracle.com/javase/specs/jls/se16/html/jls-14.html#jls-14.3 ]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20210527/1b4ff6e0/attachment-0001.htm>
More information about the compiler-dev
mailing list