> < next previous Java 9: What’s Inside By Dmytrii Shchadei
>< nextprevious
Java 9: What’s InsideBy Dmytrii Shchadei
>< nextprevious
What’s inside?‣ Project Jigsaw
‣ New Language Features
‣ Updates to API
‣ …
>< nextprevious
Project Jigsaw
>< nextprevious
‣ Project Jigsaw
‣ Module System in the Java Language
‣ Apply Module System to JDK
>< nextprevious
JAR Hell
‣ Unexpressed Dependencies
‣ Class Shadowing
‣ Version Conflicts
‣ Complex class loading
>< nextprevious
Java Module Heaven
‣ Explicit Dependencies
‣ Reliable Encapsulation
‣ Versioning 😭
>< nextprevious
Modules in Practise
>< nextprevious
JDK modularization
>< nextprevious
JDK modularization
Compiled class
files for the base
JRE
>< nextprevious
More JDK Changes
‣ Encapsulates most JDK internal API
‣ sun.misc.Unsafe
‣ sun.misc.Base64Encode/Decoder
‣ Remove 6 deprecated APIs (i.e. add/remove
PropertyChangeListener)
‣ Modules shared with Java EE not resolved by default
‣ New version-string format (i.e.
$MAJOR.$MINOR.$SECURITY)
>< nextprevious
New version-string
format‣ Encapsulates most JDK internal API (i.e.
sun.*)
‣ Remove 6 deprecated APIs (i.e. add/remove
PropertyChangeListener)
‣ Modules shared with Java EE not resolved by
default
‣ New version-string format
>< nextprevious
Jlink
‣ –module-path specifies where to find the
modules for the JDK.
‣ –add-modules adds the modules we need
‣ –limit-modules limits to just the modules that
we know our application needs (transitive
deps)
‣ –output is this directory where the run-time
image will be
Remember
Java 8
Compact
Profiles?
>< nextprevious
Migration: Bridging
CodeModule type Origin Exports packages Can read modules
(Named) Platform Modules provided by JDK explicitly
(Named) Application Modules any JAR containing
module-info.class
on the module path
explicitly Platform
Application
Automatic
Automatic Modules any JAR without
module-info.class
on the module path
all Platform
Application
Automatic
Unnamed
Unnamed Module all JARs and classes
on the classpath
all Platform
Automatic
Application
>< nextprevious
Migration: jdeps
>< nextprevious
Multi-Release Jars
>< nextprevious
JShell
>< nextprevious
New Language
Features
>< nextprevious
More concise try-with-resources
>< nextprevious
Private Interface
Methods
‣ Must be implemented
‣ Can not be overridden
‣ Can only be called in a same source file
>< nextprevious
Diamond OperatorWith Anonymous Inner Class
>< nextprevious
Diamond OperatorWith Anonymous Inner Class
>< nextprevious
SafeVarargs on Private
Methods
>< nextprevious
New API
>< nextprevious
Additions To Optional‣ Use Optional::stream to map an Optional to a
Stream.
‣ Use Optional::or to replace an empty Optional
with the result of a call returning another
Optional.
‣ With Optional::ifPresentOrElse you can do
both branches of an isPresent-if.
>< nextprevious
Additions To Objects
‣ requireNonNullElseGet
‣ requireNonNullElse
>< nextprevious
Additions to Process
API‣ Obtaining the PID with getPid()
‣ Obtaining process information ProcessHandle.Info
‣ Enumerating System Processes
ProcessHandle.allProcesses()
‣ Enumerating Child Processes
ProcessHandle.current().children()
‣ Triggering actions on process termination
ProcessHandle's onExit()
‣ Better Use of Hardware
>< nextprevious
Collection Factories
All
immutable!
>< nextprevious
Reactive StreamsJDK 9 Flow API at a Glance
>< nextprevious
Stack-Walking APIWho called me?
>< nextprevious
Stack-Walking APIWho called me?
‣ The forEach Method
‣ Walk the walk
why does it
not just
return the
Stream?
>< nextprevious
Stack-Walking APIWho called me?
>< nextprevious
Free Lunch!
‣ Multiple String Performance Improvements
‣ Better Graphics Performance
‣ Faster Compilation
‣ Better Use of Hardware