Fwd: Why can modules not be annotated?
Paul Benedict
pbenedict at apache.org
Tue Mar 22 15:31:28 UTC 2016
Mark,
>> *) Allow annotations on the module to express the custom attributes that
>>> you've spec-ed out.
Ah, my apologies for amalgamating ideas. The heart of my proposal was
regarding javax.tools annotations to synthesize module-info.java, but I
accidentally snuck it something different. Hence, what I write below should
clarify this bullet point. Please regard below as part of
#ModuleAnnotations.
Although tools will have the ability to manipulate bytecode to add custom
attributes, I find it particularly limiting there is no way for developers
to do the same in source. Assuming custom attributes are opaque strings,
then I propose something like this:
@Repeatable(ModuleAttributes.class)
@Retention(RUNTIME)
@Target(ElementType.MODULE)
@Documented
public @interface ModuleAttribute {
String name();
String value();
}
For example, Remi recently proposed an idea to deprecate modules [1]. I
then opined Remi's proposal could be related to #StandardModuleAttributes
[2], if there was a desire to give modules more information for tools to
consume (such as the deprecated module name's replacement). Absent constant
strings that specify standard module attribute names, I'll just specify my
own:
@Deprecated
@ModuleAttribute("replacement", "org.xyz.qux.2")
module org.xyz.qux { }
PS: If you decide to let modules be annotated, and then allow
@ModuleAttributes to exist, is there any point at all in "custom
attributes" in the Module_attribute structure [3]?
[1]
http://mail.openjdk.java.net/pipermail/jpms-spec-experts/2016-March/000263.html
[2]
http://mail.openjdk.java.net/pipermail/jpms-spec-observers/2016-March/000322.html
[3] http://cr.openjdk.java.net/~mr/jigsaw/spec/lang-vm.html
Cheers,
Paul
On Mon, Mar 21, 2016 at 6:49 PM, <mark.reinhold at oracle.com> wrote:
> 2016/3/9 8:50 -0800, pbenedict at apache.org:
> > I am proposing a standard set of source retention annotations that
> > developers write and tools consume to build the module-info.java
> > automatically.
>
> I think I understand your proposal for a javax.tools.Export annotation
> for use on packages. The idea there is that a developer could write
> @Export in a package-info.java file, and a tool could interpret that to
> add an appropriate `exports` directive to a synthesized module-info.java
> file.
>
> I'm still confused, however, by your earlier statement
>
> >>> *) Allow annotations on the module to express the custom attributes
> that
> >>> you've spec-ed out.
>
> Who's the "you" in this sentence? What annotations do you have in mind
> here?
>
> > PS: This is a different issue than those who want to annotate statements
> in
> > module-info.java.
>
> Understood.
>
> - Mark
>
More information about the jpms-spec-comments
mailing list