11 Refining dependencies and APIs

This chapter covers

  • Handling dependencies that are part of a module’s API
  • Aggregating and refactoring modules without breaking clients
  • Defining optional dependencies
  • Writing code in the face of absent dependencies
  • Exporting packages to selected modules only

Chapter 3 explains how requires and exports directives are the basis for readability and accessibility. But these mechanisms are strict: every module has to be explicitly required, all required modules have to be present for the application to compile and launch, and exported packages are accessible to all other modules. This suffices for the majority of use cases, but there’s still a significant portion in which these solutions are too broad.

The most obvious ...

Get The Java Module System now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.