annotations

Evan Cowden evan38109 at gmail.com
Fri Apr 17 15:15:08 EDT 2009


> I guess your argument against annotations doesn't translate into support
> for the 'requires' keyword in module-info.java, right? We need some way
> for a Java compiler to read raw dependency data, and for
> module-system-specific metadata to qualify that data. Hence my proposal:
>
> // Non-dependency, post-classloading annotations make sense up here
> @Copyright("Alex")
> module M @ 1.5 {  // Or M : 1.5 as per Paul's comments
>
>    requires FOO BAR QUUX N at 1.6;
>      // FOO BAR QUUX interpreted by a module system, to be identified
>      // an attribute in module-info.class.
> }
>
> Alex

Interesting idea.  It's a move in the right direction, but I think
you're still going to have the same problems.

Let's flesh out that example:

// You need to import the annotation classes
import com.alex.Copyright;
import com.sun.jigsaw.annotations.Jigsaw;
import org.osgi.annotations.OSGi;

// Non-dependency, post-classloading annotations make sense up here
@Copyright("Alex")
@Jigsaw("...")
@OSGi("...")
module M @ 1.5 {  // Or M : 1.5 as per Paul's comments

   requires FOO BAR QUUX N at 1.6;
     // FOO BAR QUUX interpreted by a module system, to be identified
     // an attribute in module-info.class.
}

If the module-info.java works in the same was as package-info.java -
at least in my understanding - then we'll wind up with a
module-info.class.  This is then read in by the module system through
the classloading process.  The classloader hits those import
statements for the annotations and immediately replies, "huh?"
(Forgive me if I'm mischaracterizing classloaders.)  The class never
gets successfully loaded and you still can't get your metadata.

Meanwhile, let's say that I'm trying to get my module to work in two
module systems - for the purposes of this example, Jigsaw and OSGi.
Whenever I load it into Jigsaw, I need to import the module with
OSGi's annotations (which are hopefully set up to be read by Jigsaw),
and visa versa.  This isn't the end of the world, but with multiple
module systems and user extensions for each, it's not hard to start
imagining some real nightmare scenarios.

 - Evan Cowden


More information about the jsr294-modularity-observer mailing list