3 Defining modules and their properties
This chapter covers
- What modules are, and how module declarations define them
- Discerning different types of modules
- Module readability and accessibility
- Understanding the module path
- Building module graphs with module resolution
We’ve talked a lot about modules already. They’re the core building blocks not only of modular applications, but also of a true comprehension of the module system. As such, it’s important to build a deeper understanding of what they are and how their properties shape a program’s behavior.
Of the three essential steps of defining, building, and running modules, this chapter explores the first (for the other two, see chapters 4 and 5). This chapter explains in detail what a module is and how a module’s declaration defines its name, dependencies, and API (section 3.1). Some examples from the JDK give you a first look at the module landscape we’re going to explore from Java 9 on and categorize the kinds of modules to help you navigate.
We also discuss how the module system—and, by extension, the compiler and runtime—interact with modules (sections 3.2 and 3.3). Last but not least, we examine the module path and how the module system resolves dependencies and builds a graph from them (section 3.4).