Support for multiple modules in one JAR-File

Stefan Fuchs snfuchs at gmx.de
Sat Sep 12 09:49:50 UTC 2015


Hi,

reading the State of the Module System, I got the impression that a 
modular jar file can only contain one module.

However, many applications, I have seen, fold all its dependencies into 
one big jar file (See [1]m [2] and [3] for tool support).
This is done to:
* reduce startup times for webstart applications
* ease distribution and deployment
* enable efficient obfuscating of the resulting jar (see [4])

So I think it is critical to support multiple modules in one jar file, 
if the module system is to be adopted beyond the jdk.

In this context I find the convention, of placing a module-info.java or 
module-info.class in the root of the jar file, a poor choice.
It should be named after the module name (e.g.: 
com-foo-bar-module-info.java).

Besides, I think using a simple text file to declare the module 
dependencies would have been the better option.
No special tools would be needed to inspect the dependencies of a jar 
file, when the source is not available.

- Stefan


[1] 
https://maven.apache.org/plugins/maven-assembly-plugin/descriptor-refs.html#jar-with-dependencies
[2] https://github.com/shevek/jarjar
[3] https://ant.apache.org/manual/Tasks/jar.html
[4] http://proguard.sourceforge.net/



More information about the jpms-spec-comments mailing list