alternative packaging; module declaration not packaged with module contents

Alan Bateman Alan.Bateman at oracle.com
Thu Jul 28 11:12:07 UTC 2016


On 28/07/2016 10:42, Andrew Dinn wrote:

> :
> Well, that is a complete surprise to me. I have not seen this explained
> or documented anywhere.
>
> Could you point me at the relevant documentation so I can understand
> how I need to configure such a split deployment or at least provide me
> with more details?
>
(I've changed the subject line).

OOTB, the JDK supports modular JARs and exploded modules at compile-time 
and run-time. There is also a niche format called JMOD for packaging 
modules that are only consumed at link time, interesting when creating 
custom run-time images with jlink, probably not interesting in this thread.

If you want to use alternative packaging, or store the module 
declarations separate to the module contents, then you will need to 
develop your own ModuleFinder. There are are a number of classes in the 
API that need to be implemented but it shouldn't be too difficult. One 
method to point out is ModuleDescriptor.read to read the binary form and 
combine it with the set of packages in the module. All the docs are 
online [1]. This all assumes you are doing dynamic configuration and 
creating your own layer of modules of course, there is nothing that 
allows using custom packaging formats during startup (chicken 'an egg 
issue of course).  I don't have a suggestion for compile-time but from 
your other mail then it sounds more like patching, no mention of 
recompiling modules.

BTW: One thing that would be useful is to provide one or two examples. 
If my module `exports foo.math` and `exports foo.math.function` for 
example, then it's hard to see why you would be changing it, at least 
not if you aren't shading it. Ditto for `uses` and `provides`.  So I 
think/assume you are mostly thinking about `requires`.

-Alan

[1] http://download.java.net/java/jigsaw/docs/api/index.html


More information about the jigsaw-dev mailing list