We started this chapter looking at two issues with the Java platform:
- The monolithic runtime
- The lack of API encapsulation features
Interestingly, the modularization of the Java platform provides solutions to both these problems.
There is a distinct advantage of knowing which platform modules your application belongs to. It is a clear indication of which platform modules it doesn't need--which is anything the modules in the application doesn't use! So, for example, if your application contains modules that only require
the platform modules java.base
and java.logging
, you can essentially create a small subset of the Java platform consisting of just those two modules. That slice of the platform is all that your application needs to function. If you are bundling the runtime with your application, you now know the exact portion of the runtime you need to bundle, no more no less!
Java 9 comes with a brand-new static linking step that lets you...