Modular Development with JDK 9

What does strong encapsulation mean in JDK 9?  How do you migrate your current application to modules? Alex Buckley explains in great detail the key concepts behind modules.  He describes how the module system can improve the structure of your code, how you can migrate your application progressively by mixing modular and non-modular code, and how a modular JDK enables better compatibility.  

With JDK 9, you can still run your applications on the classpath. The new module system is built into the Java language and the virtual machine. Your applications and the libraries you use can be packaged, tested and deployed as modules managed by the module system. A module is essentially a set of packages that make sense being grouped together and is designed for reuse.  Since the full platform is modular, the modular system is more reliable, easier to maintain and secure. Those benefits are shown in examples described through out this presentation.  

The main goals of the module system are to improve security with strong encapsulation and stability with reliable dependencies. Before JDK 9, you could not fine tune public access restrictions and many APIs got exposed. Modules have concealed packages for internal use and exported packages for shared code with other modules. You can also specify which classes can be shared with which modules or you can set them to be accessible to any modules. Public on a class declaration no longer means accessible to everyone. 

How do you migrate an existing application? You probably won't migrate an entire application to the module system all at once. Code in modules and traditional JARs on the classpath will coexist in your applications. Java 9 has tools to ease the migration. For example, jdeps helps you find Java class dependencies -  You run jdeps tool on the application jars.  It scans class files or jar files and tells you what code from other jar files that code depends on - You don’t have to change your traditional JARs file to run them on the module path. While demonstrating the migration of a simple JSON application, Alex explains in great detail how to define module requirements using jdeps, how to automatically create modules, export them and much more.  


Chapters to help you navigate the video content:

Part 1: Programming in the Large (2:12)
Java Base Module (5:40)
Encapsulation in JDK 9 (6:30)
Running a Modular application (13:56)
Maven and JDK 9 (16:05)
Part 2: Migrating to Modules (24:56)
Automatic Modules (32:19)
Key points to remember about the Migration to Modules (34:08)
Part 3: Modular JDK (34:30)
Compatibility with the Modular JDK (37:15)
Modular JDK Summary (39:37)

Related blogs: 

Get Ready for Java 9
JDK 9 Language, Tooling and Library Features 

More information about module system and JDK 9 can be found online: 
JEP 261: Module System 
JEP 200: The Modular JDK 
JDK 9 release 
Release notes  
Java 9 expert insights
JDK 9 documentation 
Migration guide
Java SE & JDK 9 API Specification
Oracle JDK 9 and JRE 9 Certified System Configurations

Related blog: Modular Development with JDK 9 
Two editions of Java Magazine are dedicated to Java 9. Register for free! 

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.