Class ModuleSystemExamples
java.lang.Object
net.jrodolfo.java_evolution.java09.module_system.ModuleSystemExamples
Demonstrates the Java Platform Module System (JPMS), introduced in Java 9.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classCaptures child process output. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncompileModules(Path sourceRoot, Path moduleOutputDirectory) Compiles all module source files under a module source root.voidcreateModularSourceTree(Path sourceRoot) Creates a small modular source tree with one library module and one application module.voidcreateSourceTreeWithInternalPackageAccess(Path sourceRoot) Creates a modular source tree where the app module incorrectly imports an unexported package from the greetings module.runApplicationModule(Path moduleOutputDirectory) Runs the modular application.
-
Constructor Details
-
ModuleSystemExamples
public ModuleSystemExamples()
-
-
Method Details
-
createModularSourceTree
Creates a small modular source tree with one library module and one application module.- Parameters:
sourceRoot- root directory for the module source tree- Throws:
IOException- when source files cannot be written
-
createSourceTreeWithInternalPackageAccess
Creates a modular source tree where the app module incorrectly imports an unexported package from the greetings module.- Parameters:
sourceRoot- root directory for the module source tree- Throws:
IOException- when source files cannot be written
-
compileModules
public ModuleSystemExamples.CommandResult compileModules(Path sourceRoot, Path moduleOutputDirectory) throws IOException, InterruptedException Compiles all module source files under a module source root.- Parameters:
sourceRoot- root containing module directoriesmoduleOutputDirectory- output directory for compiled modules- Returns:
- compiler process result
- Throws:
IOException- when the compiler cannot be started or source files cannot be listedInterruptedException- when interrupted while waiting for the compiler
-
runApplicationModule
public ModuleSystemExamples.CommandResult runApplicationModule(Path moduleOutputDirectory) throws IOException, InterruptedException Runs the modular application.- Parameters:
moduleOutputDirectory- directory containing compiled modules- Returns:
- Java process result
- Throws:
IOException- when the child JVM cannot be startedInterruptedException- when interrupted while waiting for the child JVM
-