Subremes Codes

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.  

The module system is a big part of the JDK 9 release, which is planned for September. With JDK 9, you will still be able to 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:36)
Encapsulation in JDK 9 (5:39)
Running a Modular application (15:01)
Where are the version numbers? (20:00)
Maven and JDK 9 (17:22)
Part 2: Migrating to Modules (23:04)
Running Jdeps (26:32)
Automatic Modules (30:01)
Key points to remember about the Migration to Modules (37:43)
Part 3: Modular JDK (38:05)
The module names (38:08)
Compatibility with the Modular JDK (42:01)
Running on the Modular JDK (46:18)

The JDK 9 release is proposed for September 2017.  You can now test your application with JDK 9 early access, which is available at jdk9.java.net. This blog ramps up your knowledge of Java 9, the module system and migration options. You should also consider the following two blog: 

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

More information about module system can be found online: 
JEP 261: Module System 
JEP 260: Encapsulate Most Internal APIs
JEP 223: New Version String Scheme 
JEP 220: Modular Runtime Image 
JEP 200: The Modular JDK 

JEP 220: Modular run-time images 
JEP 282: The Java Linker (jlink) 
JEP 260: Encapsulate Most Internal APIs 
 JDeps tool
Java 9 early access
OpenJDK project 

 

 

Статья полностью:Modular Development with JDK 9

Login