Prototype: more extensible and human-readable module metadata
Shi Jun Zhang
zhangshj at linux.vnet.ibm.com
Fri Mar 23 00:43:50 PDT 2012
On 3/22/2012 11:06 PM, David Bosschaert wrote:
> 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
>
Hi David,
Here is the commentary on module-metadata formats [1] for your reference
if you have not read it. Also there is a requirement of extensible
module declarations[2] in that document, but it seems has not been
implemented yet. I think we can involve jigsaw-dev in this discussion.
If we want to align with OSGi, why don't we use OSGi metadata format
directly?
[1]
http://openjdk.java.net/projects/jigsaw/doc/draft-java-module-system-requirements-12#_C
[2]
http://openjdk.java.net/projects/jigsaw/doc/draft-java-module-system-requirements-12#extensible-module-declarations
--
Regards,
Shi Jun Zhang
More information about the penrose-dev
mailing list