The Java Module System
Nicolai Parlog
  • MEAP began March 2017
  • Publication in Spring 2018 (estimated)
  • ISBN 9781617294280
  • 275 pages (estimated)
  • printed in black & white

Java's much-awaited "Project Jigsaw" is finally here! Java 9 will include a built-in modularity framework, and The Java Module System is your guide to discovering it. In this new book, you'll learn how the module system improves reliability and maintainability and can be used to reduce tight coupling of system components. You'll then discover how to build, compile, and run your own fully modular applications with best practices and expert techniques. Along the way, you'll also explore Java 9's compatibility challenges and how to migrate your application to the module system.

"The best book about the Java Module System."

~ Ivan Milosavljevic, Senior Software Developer, Novomatic Lottery Solutions

"Really clean, clear code. If only everybody would write like that..."

~ Mark Dechamps, Java/Spring/JPA developer, Agfa HealthCare

"A very pragmatic book that doesn't waste time in useless information"

~ Guido Pio Mariotti, Research Engineer, Linkoping University

"Gripping and interesting"

~ Maria Gemini, Student

Table of Contents detailed table of contents

Part 1: Hello, Modules

1. First piece of the puzzle

1.1. What is modularity all about?

1.1.1. Visualizing software as graphs

1.1.2. The impact of design principles

1.1.3. What modularity is all about

1.2. Module erasure before Java 9

1.3. Complications before Java 9

1.3.1. Unexpressed dependencies

1.3.2. Shadowing

1.3.3. Version conflicts

1.3.4. Complex class loading

1.3.5. Weak encapsulation

1.3.6. Manual Security

1.3.7. Startup Performance

1.3.8. Rigid Java Runtime

1.4. Bird's-eye view on the module system

1.5. Goals of the module system

1.5.1. Reliable configuration

1.5.2. Strong encapsulation

1.5.3. Improved security and maintainability

1.5.4. Improved performance

1.5.5. Scalable platform

1.5.6. Non-Goals

1.6. Skills, old and new

1.6.1. What you will learn

1.6.2. What you should know

1.7. Summary

2. Anatomy of a modular application

2.1. The application—monitoring services

2.2. Modularizing the application

2.2.1. Cutting the application into modules

2.2.2. Laying files out in a directory structure

2.2.3. Module declarations (and descriptors)

2.2.4. Writing code is much like before

2.2.5. Compiling and packaging modules

2.2.6. Running the application

2.3. Post mortem—effects of the module system

2.3.1. What the module system does for us

2.3.2. What else the module system can do for us

2.4. Summary

3. Defining modules and their properties

3.1. Modules—the building blocks of modular applications

3.1.1. Java modules (JMODs)--shipped with the JDK

3.1.2. Modular JARs—home-grown modules

3.1.3. Module declarations—defining a module's properties

3.1.4. Types of modules

3.2. Readability—connecting the pieces

3.2.1. Achieving reliable configuration

3.2.2. Unreliable configurations

3.3. Accessibility—defining public APIs

3.3.1. Achieving strong encapsulation

3.3.2. Encapsulating transitive dependencies

3.3.3. Encapsulation skirmishes

3.4. Summary

4. Building modules from source to JAR

4.1. Organizing the project in a directory structure

4.1.1. New convention?

4.1.2. Established default

4.1.3. The place for module declarations

4.2. Compiling a single module

4.2.1. Using the module path

4.2.2. Simple compilation

4.2.3. Incremental compilation

4.3. Compiling multiple modules

4.3.1. The naive approach

4.3.2. The module source path

4.3.3. The asterisk as a token for the module name

4.3.4. Multiple module source path entries

4.3.5. Setting the initial module

4.3.6. Is it worth it?

4.4. Compiler options

4.5. Packaging a modular JAR

4.5.1. Quick recap of jar

4.5.2. Analyzing a JAR

4.5.3. Defining an entry point

4.5.4. Archiver options

4.6. Summary

5. Running modular applications

5.1. The module path

5.1.1. Module resolution

5.1.2. Module graph

5.1.3. Adding modules to the graph

5.1.4. Accessibility

5.2. Launching the JVM with modules

5.2.1. Specifying the main class

5.2.2. Passing parameters

5.3. Debugging modular applications

5.3.1. Analyzing individual modules

5.3.2. Validating sets of modules

5.3.3. Validating a module graph

5.3.4. Listing observable modules and dependencies

5.3.5. Excluding modules during resolution

5.3.6. Logging

5.4. Java Virtual Machine options

5.5. Summary

Part 2: Real World Applications

6. Compatibility challenges when moving to Java 9

6.1. Encapsulation of internal APIs

6.1.1. Internal APIs under the microscope

6.1.2. Analyzing dependencies with JDeps

6.1.3. Compiling against internal APIs

6.1.4. Executing against internal APIs

6.1.5. Compiler and JVM options for accessing internal APIs

6.2. Working with Java EE modules

6.2.1. Why are the Java EE modules special?

6.2.2. Resolving Java EE modules

6.2.3. Upgrading Java EE modules

6.3. Mending split packages

6.3.1. What is the problem with split packages?

6.3.2. The effects of split packages

6.3.3. Many ways to handle split packages

6.3.4. Patching modules

6.3.5. Finding split packages with JDeps

6.3.6. A note on dependency version conflicts

6.4. Selecting, replacing, and extending the platform

6.4.1. Compact profiles

6.4.2. Extension mechanism

6.4.3. Endorsed standards override mechanism

6.4.4. Boot class path

6.4.5. Compiling for Java 5

6.4.6. JRE version selection

6.5. The little things that make big things fail

6.5.1. Casting to URLClassLoader

6.5.2. New Version Strings

6.5.3. Runtime image directory layout

6.5.4. Tool exodus

6.5.5. The littlest things

6.6. Migration strategies

6.6.1. Preparatory updates

6.6.2. Estimating the effort

6.6.3. Continuously build on Java 9

6.6.4. Thoughts on command line options

6.7. Summary

7. Modularizing existing applications

8. Services — configuring applications with the module path

9. Refining dependencies and APIs

10. Reflection in a modular world

11. Runtime images with jlink

12. Troubleshooting

Appendixes

Appendix A: Basics of the class path

Appendix B: High-level introduction to the reflection API

Appendix C: Observing the JVM with unified logging

Appendix D: Analyzing a project’s dependencies with JDeps

About the Technology

Experienced developers understand the benefits of strong encapsulation; when two components can interact only through the interfaces you define, you reduce the chance that you'll introduce hidden dependencies and unwanted tight coupling into your code. The Java Module System, aka "Project Jigsaw", gives Java developers the ability to define and enforce modularity without an outside framework. A modular application allows a team to more-safely approach large projects and produce cleaner code with superior run-time stability. The benefits don't just stop there however, the shift to modules also promises reliable configuration - allowing individual modules to declare their dependencies on other modules, along with allowing both the developers and JVM the same vision of the running application; changing how you develop with Java for the better!

What's inside

  • The anatomy of a modular Java app
  • Building modules from source to JAR
  • Compiling both single and multiple modules
  • Debugging your finished applications

About the reader

If you are a developer who has experience working with Java, then this book is perfect for you.

About the author

Nicolai Parlog is a thirty year old boy, as the narrator would put it, who has found his passion in software development. He constantly reads, thinks, and writes about it, and codes for a living as well as for fun. He is the editor of SitePoint's Java channel, blogs about software development on codefx.org, and is a long-tail contributor to several open source projects. The best way to get in touch is via Twitter.

Manning Early Access Program (MEAP) Read chapters as they are written, get the finished eBook as soon as it’s ready, and receive the pBook long before it's in bookstores.
Buy
MEAP combo $44.99 pBook + eBook + liveBook
MEAP eBook $35.99 pdf + ePub + kindle + liveBook

FREE domestic shipping on three or more pBooks