Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Java 9: Building Robust Modular Applications

You're reading from   Java 9: Building Robust Modular Applications Master advanced Java features and implement them to build amazing projects

Arrow left icon
Product type Course
Published in Apr 2018
Publisher Packt
ISBN-13 9781788832823
Length 910 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (3):
Arrow left icon
Dr. Edward Lavieri Jr. Dr. Edward Lavieri Jr.
Author Profile Icon Dr. Edward Lavieri Jr.
Dr. Edward Lavieri Jr.
Jason Lee Jason Lee
Author Profile Icon Jason Lee
Jason Lee
Peter Verhas Peter Verhas
Author Profile Icon Peter Verhas
Peter Verhas
Arrow right icon
View More author details
Toc

Table of Contents (33) Chapters Close

Title Page - Courses
Packt Upsell - Courses
Preface
1. The Java 9 Landscape FREE CHAPTER 2. Discovering Java 9 3. Java 9 Language Enhancements 4. Building Modular Applications with Java 9 5. Migrating Applications to Java 9 6. Experimenting with the Java Shell 7. Leveraging the New Default G1 Garbage Collector 8. Microbenchmarking Applications with JMH 9. Making Use of the ProcessHandle API 10. Fine-Grained Stack Tracing 11. New Tools and Tool Enhancements 12. Concurrency and Reactive Programming 13. Security Enhancements 14. Command Line Flags 15. Best Practices In Java 9 16. Future Directions 17. Introduction 18. Managing Processes in Java 19. Duplicate File Finder 20. Date Calculator 21. Sunago - A Social Media Aggregator 22. Sunago - An Android Port 23. Email and Spam Management with MailFilter 24. Photo Management with PhotoBeans 25. Taking Notes with Monumentum 26. Serverless Java 27. DeskDroid - A Desktop Client for Your Android Phone 28. What is Next? 1. Bibliography
Index

Breaking the monolith


Over the years, the utilities of the Java platform have continued to evolve and increase, making it one big monolith. In order to make the platform more suitable for embedded and mobile devices, the publication of stripped down editions such as Java CDC and Java ME was necessary. These, however, did not prove to be flexible enough for modern applications with varying requirements in terms of functionality provided by the JDK. In that regard, the need for a modular system came in as a viral requirement, not only to address modularization of the Java utilities (overall, more than 5000 Java classes and 1500 C++ source files with more than 25,0000 lines of code for the Hotspot runtime), but also to provide a mechanism for developers to create and manage modular applications using the same module system used in the JDK. Java 8 provided an intermediate mechanism to enable applications to use only a subset of the APIs provided by the entire JDK, and that mechanism was named compact profiles. In fact, compact profiles also provided the basis for further work that had to be done in order to break dependencies between the various distinct components of the JDK required to enable implementation of a module system in Java.

The module system itself has been developed under the name of project Jigsaw on the basis of which several Java enhancement proposals and a target JSR (376) were formed. Much was put in place to address the requirements of project Jigsaw--there was evidence of concept implementation with more features proposed than the ones that successfully made it into Java 9. Apart from that, a complete restructuring of the JDK code base has been made along with a complete reorganization of the JDK distributable images.

There was considerable controversy in the community as to whether an existing and mature Java module system such as OSGi should be adopted as part of the JDK instead of providing a completely new module system. However, OSGI targets runtime behavior such as the resolution of module dependencies, installation, uninstallation, starting and stopping of modules (also named bundles in terms of OSGI), custom module classloaders, and so on. Project Jigsaw however targets a compile-time module system where resolution of dependencies happen when the application is compiled. Moreover, installing and uninstalling a module as part of the JDK eliminates the need to include it as a dependency explicitly during compilation. Furthermore, loading of module classes is made possible through the existing hierarchy of classloaders (the bootstrap and the extension and system classloaders), although, there was a possibility of using custom module classloaders pretty much similar to the module classloaders of OSGI. The latter was, however, abandoned; we will discuss Java module classloading in more detail when we talk about the details of the module system in Java.

Additional benefits from the Java module system include enhanced security and performance. By modularizing the JDK and applications into Jigsaw modules, we are able to create well-defined boundaries between components and their corresponding domains. This separation of concerns aligns with the security architecture of the platform and is an enabler of better resource utilization. We have dedicated two detailed chapters to all of the preceding points, and to the topic of adopting Java 9 as well, which also requires a degree of understanding on the possible approaches to migrating existing projects to Java 9.

You have been reading a chapter from
Java 9: Building Robust Modular Applications
Published in: Apr 2018
Publisher: Packt
ISBN-13: 9781788832823
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image