Refactoring your code to Java 9 modules
summary
Migrating a monolith into Java 9 modules uses concrete steps: analyze with DeGraph to find cyclic package deps, refactor packages into model / db / ui layers, add module descriptors via module-info.java, and replace direct UI–domain links with interfaces and the ServiceLoader to break cycles. Example converts a 42,000-class, 3,800-package OSGi codebase split into 285 plugins into a small vet app, then duplicates the pet module into a car module; building with jlink produces a ~40 MB runtime and the modular apps run.
AI-written summary · about
chapters (11)
- 0:00Introduction to refactoring
- 10:48Identifying modules in code
- 15:02Java 9 module system overview
- 18:13Creating module-info.java
- 24:14Refactoring to modules
- 31:43Resolving cyclic dependencies
- 33:12Using services for dependencies
- 38:57Replacing pets with cars
- 41:47Compiling and deploying modules
- 43:14Summary and benefits of modules
- 46:47Q&A and resources








