With Java 9, modularity comes to your doorstep (whether you ordered it or not). This isn't your average language feature: making the most out of it may involve rewiring your brain. In this session we explore the benefits of a modular codebase using Java 9 modules. Because who doesn’t like more reliable and secure applications, meanwhile killing the dreaded classpath?
After reviewing the basic concepts of modules, we'll explore modularity patterns that enhance your design and development skills. We all have existing software, so migration of codebases to a modular world is an important topic as well. Automatic modules and other new concepts are added to your toolbox to this end.
Want examples? We've got plenty in this practical and code-driven talk. Even if you intend to use Java 9 without modules, this talk helps you prevent common issues. You'll be ready for Java 9 before you know it.
Both speakers are currently writing “Java 9 Modularity” for O’Reilly, expected early 2017. They have extensive experience under the belt already with the Java 9 Jigsaw early access builds.
15. Strong encapsulation
Hide your internals
java.base
java.lang
java.time
java.util
com.sun.*
sun.*
jdk.internal.*
my.module
requires
Access checks at VM level (even reflection)
16. Why not just use OSGi?
‣ OSGi is built on top of the JVM
‣ Can’t be used to modularise the JDK itself
17. Why not just use OSGi?
‣ OSGi is built on top of the JVM
‣ Can’t be used to modularise the JDK itself
Why not only modularise the JDK?
‣ Fair point :-)
‣ OSGi has never seen mass adoption, Java 9 will
bring modularity to all of us
30. JSR-376 linking
‣ Use a linking tool (jlink) to create a custom 'runtime
image' with only the modules you need
‣ Uses explicit dependencies from module-info.class
‣ Allows for whole-program optimization
Runtime image
java.base
java.desktop
my.mod1
my.mod2
JVM
40. Automatic Modules
‣ A plain JAR on the module path becomes an
Automatic Module
‣ Module name derived from JAR name
‣ Exports everything
‣ Reads all other modules