Préparez-vous à
la modularité
selon Java 9
Official Hashtag
- #DevoxxFR
- #PreparezVousALaModularitéSelonJava9AvecRemiForaxEtAlexisHassler
Dramatic intro
Classpath - compile time
Classpath - runtime
Scale Down
Security
- CVE-2015-6420, …
Security
Security
Modular JDK
Modular JDK
Modular JDK
Modular JDK
Deprecated JDK modules
Deprecated JDK modules
- … back to Java EE
Non-standard JDK modules
- Deleted classes
- Hidden packages
Non-standard JDK modules
- Internal modules
Module descriptor
Build module
Run module
Modular application
Modular application
Module descriptor
Export package
Multi-modules layout
- 1 project = n modules
Multi-modules layout
Create module
The Jigsaw Sandwich
The Jigsaw Sandwich
Create module
Encapsulation
Visibility
Visibility
Visibility
Split package
Regular export
Restricted export
sun.misc.Unsafe
New internal unsafe API (hidden) |
Keep sun.misc in 9, remove features when public replacement APIs exist |
Deep reflection
Deep reflection
- Open a package
- Open all the packages of the module
Module dependency
Transitive dependency
Transitive dependency
Static dependency
- Compile time only
Plain old jar
Plain old jar
- No dependency to classpath
Plain old jar
Automatic Module
- Plain old jar in module-path
Automatic Module
Mixed mode
Mixed mode
Module Service
Interface / Implementations
Interface / Implementations
User / Provider
Usage
Running on Java 9
- Compiling in Java 8
Big kill switch
This option will only be supported in JDK 9. It will be removed in JDK 10. |
Command line java / javac
- Add root module
- --add-modules
Command line java / javac
jdeps
- Diagnostic tool
- since Java 8
- jdeps --jdk-internals
Tests
Test module
Test module
- Compile time
Test module
- Test module-info.java
Test module
- Compile
Test module
- Run time
Test module
- Run
Single module
Single module
- Compile time
Single module
- Compile
Single module
- Run time
Single module
- Run
Going Native
jlink
- Custom runtime image
- Specific for a platform
- For small devices or in the cloud
jlink
Minimal VM
- size of the classical VM: 20 megs
- size of the minimal VM: 3 megs
Ahead Of Time compilation
experimental feature ! |
- Module ⇒ shared library
- .so, .dll, .dynlib
Ahead Of Time compilation
experimental feature ! |
- Run in AOT mode
Benchmarks
Benchmarks
Conclusion
Jigsaw Goals
- Reliable configuration
- No classpath anymore
- compile time / runtime fidelity
Jigsaw Goals
- Scale down the platform
- downsized unit of re-use
Jigsaw Goals
- Strong encapsulation
- Separate public types from implementation
- Enhanced security
Jigsaw Goals
- Closed World
- Ahead of time optimizations
Jigsaw Goals
- Reliable configuration
- Scale down the platform
- Strong encapsulation
- Closed World
Planning
Questions ?
Références
- Download JDK 9 Early Access
- Oracle JDK 9 Documentation
- JavaOne, DevoxxBE talks