Migration Strategy: From Automatic to Explicit Modules
You'll learn why automatic modules should be temporary stepping stones, not permanent solutions.
Automatic modules are incredibly useful during migration—they let you put legacy JARs on the module path without modifying them. However, treating them as a long-term solution is like putting a band-aid on structural damage. They lack the precision and safety guarantees that explicit modules provide.
Why Automatic Modules Are Temporary
Automatic modules have three significant weaknesses:
- They export everything — All packages become public API, even internal implementation details
- They require everything — They implicitly depend on all other modules, creating overly broad dependency graphs
- Unstable naming — Without an
Automatic-Module-Namemanifest entry, module names derive from filenames, which can change
These characteristics make automatic modules fragile foundations for production systems.
The Migration Path
Phase 1: Convert third-party JARs to automatic modules (place on module path, add Automatic-Module-Name if you control the JAR)
Phase 2: Write explicit module-info.java for your own code, using requires to reference automatic modules
Phase 3: Replace automatic modules with explicit versions:
- Contact library maintainers for modular releases
- Fork and modularize critical dependencies yourself
- Use
jdepsto understand exact package dependencies before converting
Phase 4: Validate with jdeps that all automatic modules are eliminated
Best Practices
- Document temporary workarounds — Track which dependencies remain automatic
- Monitor upstream projects — Many libraries are actively adding module support
- Prioritize by risk — Convert high-churn or security-critical dependencies first
- Test incrementally — Each automatic→explicit conversion should be validated independently
Key Takeaway: Automatic modules are bridges, not destinations—plan actively to replace them with explicit modules to achieve JPMS's full encapsulation and maintainability benefits.