This chapter covers
- Java’s platform modules
- Changes to access control semantics
- Writing modular applications
- Multi-release Jars
As mentioned in Chapter 1, versions of Java, up to and including Java 9, were delivered according to a feature-driven release plan, often with a major new capability that defined or was strongly associated with the release.
For Java 9, this feature was Java Platform Modules (also known as JPMS, Jigsaw or just "modules"). This is a major enhancement and change to the Java platform that had been discussed for many years - it was originally conceived of as potentially shipping as a part of Java 7, back in 2009/10.
In this chapter, we will explain the reasons why modules are needed, as well as the new syntax used to articulate modularity concepts and how to use them in your applications. This will enable you to use JDK and third-party modules in your build as well as packaging apps or libraries as modules.
Note
Modules represent a new way of packaging and deploying your code and adopting them will make your applications better. However, if you just want to start using modern Java features (11 or 17) then there is no need for you to adopt modules immediately unless you want to.
The arrival of modules has profound implications for the architecture of applications, and modules have many benefits to modern projects that are concerned about, such as: process footprint, startup cost and warmup time.