O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Java 9 Modularity, 1st Edition

Book Description

With Early Release ebooks, you get books in their earliest form—the author's raw and unedited content as he or she writes—so you can take advantage of these technologies long before the official release of these titles. You'll also receive updates when significant changes are made, new chapters are available, and the final ebook bundle is released.

The upcoming Java 9 module system will affect existing applications and offer new ways of creating modular and maintainable applications. With this hands-on book, Java developers will learn not only about the joys of modularity, but also about the patterns needed to create truly modular and reliable applications. Authors Sander Mak and Paul Bakker teach you the concepts behind the Java 9 module system, along with the new tools it offers. You’ll also gain learn how to modularize existing code and how to build new Java applications in a modular way.

  • Understand Java 9 module system concepts
  • Master the patterns and practices for building truly modular applications
  • Migrate existing applications and libraries to Java 9 modules
  • Use JDK 9 tools for modular development and migration

Table of Contents

  1. 1. Modularity Matters
    1. What is Modularity?
    2. Before Java 9
      1. JARs as Modules?
      2. Classpath Hell
    3. Java 9 Modules
  2. 2. Modules and the Modular JDK
    1. The Modular JDK
    2. Module Descriptors
    3. Readability
    4. Implied Readability
    5. Accessibility
      1. Qualified Exports
    6. Module Resolution and the Module Path
    7. Using the Modular JDK Without Modules
  3. 3. Working with Modules
    1. Your First Module
      1. Anatomy of a Module
      2. Naming Modules
      3. Compilation
      4. Packaging
      5. Running Modules
      6. Linking Modules
    2. No Module Is an Island
      1. Introducing the EasyText Example
      2. A Tale of Two Modules
    3. Working with Platform Modules
      1. Finding the Right Platform Module
      2. Creating a GUI Module
    4. The Limits of Encapsulation
      1. Interfaces and Instantiation
  4. 4. Services
    1. Factory Pattern
    2. Services for Implementation Hiding
      1. Providing Services
      2. Consuming Services
      3. Consumer Service Lifecycle
      4. Provider Service Lifecycle
    3. Factory Pattern Revisited
    4. Default Service Implementations
    5. Filtering and Ordering
      1. Service Type Inspection and Lazy Instantiation
    6. Module Resolution with Service Binding
    7. Services and Linking
  5. 5. Modularity Patterns
    1. Determining Module Boundaries
    2. Lean Modules
    3. API Modules
      1. Separate API and Implementation
      2. What Should Be in an API Module?
      3. Implied Readability
    4. Aggregator Modules
      1. Building a Facade Over Modules
      2. Safely Splitting a Module
    5. Avoiding Cyclic Dependencies
      1. Split Packages
      2. Breaking Cycles
    6. Optional Dependencies
      1. Compile-time Dependencies
      2. Implementing Optional Dependencies with Services
    7. Versioned Modules
      1. Module Resolution and Versioning
    8. Resource Encapsulation
      1. Loading Resources From a Module
      2. Loading Resources Across Modules
      3. Working with ResourceBundles
  6. 6. Advanced Modularity Patterns
    1. Strong Encapsulation Revisited
      1. Deep Reflection
      2. Open Modules and Packages
      3. Dependency Injection
    2. Reflection on Modules
      1. Introspection
      2. Modifying Modules
      3. Annotations
    3. Container Application Patterns
      1. Layers and Configurations
      2. Classloading in Layers
      3. Plugin Architectures
      4. Container Architectures