Revisiting the classpath problems

In Chapter 1, Introducing Java 9 Modularity, we looked at two problems faced by our friends Jack and Amit:

  • Jack couldn't easily encapsulate internal library types and prevent use of that type outside the library, while retaining the ability to freely use them inside his own library
  • Amit couldn't reliably assemble a set of compiled Java code and guarantee that all the dependencies and imports of those types are sufficiently met before the program actually hits the dependency at runtime

Have we solved these problems with the module system? Thankfully, yes!

We've already seen how the Java module's encapsulation prevents certain types from being accessed outside the module, even if the type is public, unless ...

Get Modular Programming in Java 9 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.