Class & interface terminology
Kevin Bourrillion
kevinb at google.com
Thu May 7 23:45:56 UTC 2020
On Thu, May 7, 2020 at 4:12 PM Dan Smith <daniel.smith at oracle.com> wrote:
1) JLS unambiguously says that an [annotation type/interface] is an
> interface. There's room for disagreement about whether that's a good design
> or not, but that is quite clearly what it says.
>
> https://docs.oracle.com/javase/specs/jls/se14/html/jls-9.html
> https://docs.oracle.com/javase/specs/jls/se14/html/jls-9.html#jls-9.6
>
> 2) That choice makes sense, because there are a lot of rules related to
> interfaces that apply to [annotation types/interfaces]. I gave you one
> example, but there are many:
>
> https://docs.oracle.com/javase/specs/jls/se14/html/jls-8.html#jls-8.1.5
> https://docs.oracle.com/javase/specs/jls/se14/html/jls-4.html#jls-4.3
> https://docs.oracle.com/javase/specs/jls/se14/html/jls-4.html#jls-4.7
> https://docs.oracle.com/javase/specs/jls/se14/html/jls-9.html#jls-9.2
> https://docs.oracle.com/javase/specs/jls/se14/html/jls-4.html#jls-4.10.2
> Etc.
>
> So: you may prefer a model in which classes, interfaces, enums, records,
> and annotation types are five distinct things. But this is not the model
> JLS uses, and it would be quite disruptive to refactor in that direction.
>
I was sympathetic to Remi's-as-explained-by-Alex point that the way 99% of
code will interact with it is quite unrelated to its interfaceness. Only to
the author of the annotation... thingie and to the processing code does it
actually look like an interface. So in a pedagogical context it would be a
misdeed to emphasize that interfaceness; more properly just a bit of trivia
that it happens to be surfaced to processors like an interface.
Good thing the spec is not a pedagogical context :-)
--
Kevin Bourrillion | Java Librarian | Google, Inc. | kevinb at google.com
More information about the amber-spec-observers
mailing list