Strong encapsulation

Earlier in this chapter, you read that Java 9's strong encapsulation remedied the monolithic JDK issue. Encapsulation, in Java 9, is driven by the information in the module-info.java file. The information in this file lets Java know what modules are dependent upon others and what each of them exports. This underscores the importance of ensuring our module-info-java files are properly configured. Let's look at an example written with standard Java code, nothing new in Java 9 in the way this was coded:

In the preceding example, the com.three19.irisScan module has an irisScanner package intended for internal use and an

Get Java 9: Building Robust Modular Applications 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.