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 the package they belong to is explicitly exported. Indeed, we applied the same concept to hide the BubbleSortUtilImpl class...