☕ Java
Advanced
What are Java 9 modules (JPMS)?
Answer
The Java Platform Module System (JPMS), introduced in Java 9 (Project Jigsaw), allows you to organize code into modules — named, self-describing groups of packages with explicit declarations of what they export and what they require. Each module has a module-info.java file: module com.example.myapp { requires java.sql; exports com.example.myapp.api; }. Benefits: strong encapsulation (internal packages cannot be accessed by default, unlike jars), explicit dependencies (the JVM verifies that all required modules are present at startup), and smaller JREs (you can create minimal custom runtimes with only the needed modules using jlink). The JDK itself was modularized — java.base is the foundational module all others implicitly depend on.