Technical Overview & Strategic Context
For two decades, Java applications relied on the classpath to resolve dependencies at runtime. However, the classpath model had limitations: it did not enforce encapsulation, allowing public classes to be accessed by any code, and it did not verify dependency completeness at startup, leading to ClassNotFoundException crashes at runtime. The upcoming release of Java 9 addresses this by introducing the Java Platform Module System (Project Jigsaw), which adds strong modularity and encapsulation to the JVM.
Architectural Principle: Enforce strong encapsulation at the module level. Declare public APIs explicitly using exports directives, and block access to internal implementation details.
Core Concepts & Architectural Blueprint
Project Jigsaw introduces the module-info.java configuration file, where developers define module boundaries. Modules must explicitly declare which packages they export to other modules and which modules they require as dependencies. The Java runtime verifies these dependencies at startup, preventing missing class errors in production. The module system also allows developers to create custom, lightweight JRE packages that bundle only the modules required by the application.
Performance & Capability Comparison
| Java Packaging | Pre-Java 9 Classpath | Java 9 Modular Jigsaw | Operational Benefit |
|---|---|---|---|
| Encapsulation | Public classes accessible from any package | Public classes hidden unless exported | Protects internal APIs from access |
| Dependency Verification | Dynamic loading (risk of ClassNotFoundException) | Static validation during startup | Prevents missing dependency crashes |
| JRE Size | Monolithic runtime environment (approx. 200MB+) | Custom runtime using jlink tool (approx. 40MB) | Reduces container image sizes |
Implementation & Code Pattern
To configure a modular Java project under Java 9 guidelines, developers should follow these steps:
- ◆Create a module-info.java file in the source root directory.
- ◆Specify the module name and dependencies using requires statements.
- ◆Declare public APIs using exports statements to expose packages.
- ◆Package modular applications using the jlink tool to create custom runtimes.
// module-info.java module declaration in Java 9 (2017)
module in.shivamitcs.portal {
// Require Java foundational core modules
requires java.sql;
requires java.logging;
// Export public API packages to other modules
exports in.shivamitcs.portal.api;
exports in.shivamitcs.portal.dto;
// Internal implementation packages remain hidden automatically
}Operational Governance & Future Outlook
The Java 9 Module System (Project Jigsaw) resolved key limitations of the traditional classpath. Enforcing strong encapsulation and startup verification helps teams build reliable JVM applications.