Mục tiêu chính của Project Jigsaw: Mang tính modularity vào Java 9 và áp dụng cho JDK.
Lợi ích của Modularity (Jigsaw)
| Lợi ích | Mô tả |
| Strong Encapsulation | Module chỉ truy cập phần được export rõ ràng trong module-info.java. Public class trong package không export → không public bên ngoài. |
| Clear Dependencies | Module khai báo phụ thuộc qua requires. Kết hợp module tạo runtime nhỏ gọn, scale xuống thiết bị nhỏ dễ dàng. |
| Reliable Configuration | Loại bỏ runtime error do thiếu class (ClassNotFoundException, NoClassDefFoundError). Phát hiện lỗi dependency ở compile-time/link-time. |
Các JEP (JDK Enhancement Proposal) của Jigsaw
| JEP | Tên | Mô tả |
| JEP 200 | Modular JDK | Dùng JPMS module hóa JDK thành tập module kết hợp tại build/compile/runtime. |
| JEP 201 | Modular Source Code | Module hóa source code JDK, nâng cấp build tools compile module. |
| JEP 220 | Modular Run-Time Images | Restructure JRE/JDK runtime images cho module, cải thiện security, performance, maintainability. |
| JEP 260 | Encapsulate Most Internal APIs | Chặn truy cập internal API (sun.misc...). Chỉ internal API quan trọng vẫn khả dụng qua module. |
| JEP 261 | Module System | Triển khai module system spec: thay đổi JVM, Java language, standard APIs. |
| JEP 282 | JLink: The Java Linker | Đóng gói module + dependencies thành custom runtime nhỏ gọn. |
Kiến trúc Module System
Application Modules (app code)
↓ requires
Platform Modules (java.*, jdk.*)
↓
java.base (foundation module - implicit requires)
Tác động
- JDK 9+: rt.jar, tools.jar không còn – thay bằng
jmod files / jimage.
- Classpath → Module-path cho modular app.
- Internal API (sun.misc.Unsafe, com.sun.*) bị encapsulate – migration cần thiết.
- Custom JRE cho microservice, container, IoT.
Project Jigsaw là thay đổi lớn nhất từ Java 5, định hình Java hiện đại: modular, secure, scalable.