Prototype: more extensible and human-readable module metadata
David Bosschaert
david.bosschaert at gmail.com
Thu Mar 22 08:06:00 PDT 2012
Hi all,
I have started looking at alternatives for module-info.class. I
personally find the use of a .java/.class file inappropriate for
module metadata: it’s not easily readable once compiled (you need a
tool, rather than being able to use any text editor to look at it) and
its contents are not like any java file at all, it’s rather a special
sub-language that only applies to module-info.java and is totally
separate from the rest of java.
Anyway, the biggest issue with module-info.class is that it’s hard to
extend. In the case of OSGi you’d like to extend the module metadata
with package version information, for example. So I wanted to come up
with a more extensible format that would also be readable with a
simple text editor once put in the jar file.
So I started prototyping in the Penrose codebase. I came up with
META-INF/module-info.xml as an alternative. For example, the following
module-info.java:
module org.astro.xml @ 1.2 {
exports org.astro.xml;
}
could be represented as:
<module name="org.astro.xml" version="1.2"
xmlns="http://www.jcp.org/xmlns/modules/v1.0">
<exports name="org.astro.xml"/>
</module>
You can then extend it in any arbitrary place by adding tags and
attributes in a other namespace, e.g. for OSGi:
<module name="org.astro.xml" version="1.2"
xmlns="http://www.jcp.org/xmlns/modules/v1.0"
xmlns:osgi=”http://www.osgi.org/xmlns/javamodules/v1.0”>
<exports name="org.astro.xml">
<osgi:version version="1.0"/>
</exports>
</module>
or even
<module name="org.astro.xml" version="1.2"
xmlns="http://www.jcp.org/xmlns/modules/v1.0"
xmlns:osgi=”http://www.osgi.org/xmlns/javamodules/v1.0”>
<exports name="org.astro.xml" osgi:version="1.0"/>
</module>
In my prototype I’m supporting the new format alongside the
module-info.class. If the META-INF/module-info.xml is found, that is
used, otherwise it will revert to module-info.class.
However, before I go much further, I’m wondering what people feel
about the XML format. Is it ok? Or should we go for another format?
Cheers,
David
More information about the penrose-dev
mailing list