Author: Amanda Tissot
-
Module Graph – Java Module System
•
Module Graph The structure of an application is reflected by its module graph constructed from dependencies between its modules. An important aspect of the module system is to perform module resolution at compile time and runtime to ensure that the application has a reliable configuration. This process resolves all dependencies,…
-
Accessibility Rules for Members – Java Module System
•
Accessibility Rules for Members Table 19.1 summarizes the accessibility rules for members of a public class A contained in a package pkg1 of module M. Note that class A is public so that it satisfies one of the three conditions discussed earlier for accessibility of a type from another module.…
-
Qualified Export – Java Module System
•
Qualified Export Any package that is exported by a module is readable by any module that requires its module. However, sometimes it is necessary that only certain modules can access an exported package. This can be achieved by using the exports-to directive, as shown below at (1), where packageOne in…
-
Creating a Modular Application – Java Module System
•
19.5 Creating a Modular Application After understanding the basic role of a module declaration, we can proceed to create a modular application. As support for Java modules is not quite up to par at present in integrated development environments (IDEs), we will use the command-line tools provided by the JDK.…
-
Creating the Application Directory Structure – Java Module System
•
Creating the Application Directory Structure Typically, the code for a modular application is organized in a directory structure, similar to the one shown in Figure 19.9. The modules are created in the src directory and compiled into the mods directory. The compiled modules are bundled into modular JARs and placed…
-
Better Performance – Java Module System
•
Better Performance Modules in Java contribute to developing scalable systems with improved performance, as modules can be optimized independently. The module system guarantees that all classes of the same package are in the same module—that is, there are no split packages, and the modules describe explicit dependencies. The class loader…
-
Creating the Source Files in the Exploded Modules – Java Module System
•
Creating the Source Files in the Exploded Modules The classes that are in packages included in the modules are declared in their respective source files. Example 19.1 shows the source files for the adviceApp application. The source code of the AdviceModel.java file in the model module is shown at (1)…
-
Parsing Values Using Patterns – Localization
•
Parsing Values Using Patterns An instance of the MessageFormat class can be used both for formatting and for parsing of values. The class provides the parse() methods for parsing text. We will primarily use the one-argument method shown below to demonstrate parsing with the MessageFormat class. Click here to view…
-
Compiling and Running a Modular Application – Java Module System
•
19.6 Compiling and Running a Modular Application Both the javac tool to compile Java source code and the java tool to launch an application include new command-line options to specifically support building of modular applications. When the javac tool or the java tool is called, initially a module resolution is…
-
Multi-Module Compilation – Java Module System
•
Multi-Module Compilation It is tedious compiling modules individually. It is more convenient to use the following command: Click here to view code image >javac –module-source-path src -d mods –module main The –module-source-path option (no short form), as the name suggests, indicates the src directory where the exploded modules with the…