[External] : Re: Proposal: Allow annotations on module directives

Alessandro Autiero alautiero at gmail.com
Tue Nov 12 18:47:54 UTC 2024


I've found a similar JEP which might help my case, JEP 120(Repeating
Annotations) <https://openjdk.org/jeps/120>: the aim of that JEP was to
allow developers to use multiple annotations of the same type on an
element, a limitation which was previously being addressed by developers by
using container annotations.
In the case of this hypothetical JEP, the aim is to allow developers to
annotate module directives instead of using the enclosing module definition
as a target for annotations that should actually belong to the single
directives.
I'd like to pinpoint a particular issue, but I'd argue that, as this is a
limitation of the language itself, it's impossible to find instances in the
ecosystem where this is an issue as the projects that would use this
feature can't exist yet.
Similarly, I see that in JEP 104(Type Annotations)
<https://openjdk.org/jeps/104> the Checker Framework existence is used as a
success metric, but that project could be built only after annotations
could be applied to types.
If I had to find a possible application of this JEP similar to the Checker
Framework for JEP 104, I'd say that a build system's dependency management
could be built only around the module-info instead of having a seperate
file like in the case of Maven or Gradle.
I could also research on public code platforms such as GitHub how often
annotations that target a module contain attributes that could/should be
delegated to a particular directive, assuming the sample size isn't too
large and that this data point isn't considered too subjective.
I've included this possibility as last as I don't see any indication that
any similar work was done for JEP 120, where the only claimed motivation

> Frequently-used idioms of programming with annotations in EE and elsewhere
> awkwardly use a container annotation just to simulate the ability to apply
> multiple annotations

seems to be purely anecdotal.


Il giorno mar 12 nov 2024 alle ore 16:59 Ron Pressler <
ron.pressler at oracle.com> ha scritto:

>
>
> > On 12 Nov 2024, at 15:25, Alessandro Autiero <alautiero at gmail.com>
> wrote:
> >
> >
> > I'd argue that it's not consistent to allow the members of
> TypeDeclarations to be annotated, while not doing the same for
> ModuleDeclaration's.
> > I won't argue that this is a large issue: most developers will never
> write an annotation processor, let alone one that walks through a module,
> but not being able to annotate the directives that define most of the
> metadata of a module is a major limitation to the annotation system in this
> scope.
> > I'll also mention the fact that in the javadocs at
> ModuleElement$DirectiveKind it's clearly stated that new module directives
> might be introduced in future versions, so supporting annotations might be
> a "nice to have" for that scenario, but this is purely hypothetical.
>
> I would suggest to first identify some actual problems that this would
> solve. I don’t think that an inconsistency *in itself* is enough to justify
> a feature.
>
> — Ron
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/compiler-dev/attachments/20241112/0161ca82/attachment.htm>


More information about the compiler-dev mailing list