Java 9 sneak peek
Who am I
Software consultant (CoffeeCupConsulting)
BG JUG board member (http://jug.bg)
OpenJDK and Oracle RBDMS enthusiast
Twitter: @martin_fmi
Agenda
• Java 9: module system
• Networking break
• Java 9: the good parts
Java 9: module system
Goals
• Break the monolith JDK into smaller modules
• Provide module system for Java applications
java.base
java.logging
java.xml
java.sql
Supporting work …
• JDK 8 compact profiles
javac -profile <profile_name>
compact 1 compact 2 compact 3
Module metadata
• Provided by module-info.java
• Extends the syntax of the Java language
• Exposed at runtime via the java.lang.Module class
Module metadata
module application.demo {
requires java.logging;
requires banking.server;
provides
bg.jug.banking.server.applications.BankingApplication
with bg.jug.banking.app.demo.DemoApplication;
}
Module module = object.getClass().getModule();
Java 9: module systemdemo
Java 9: the good parts
Sneak peek
• Java Shell (JShell)
• New process API
• Small language enhancements
• G1 as the default garbage collector
Sneak peek
• New HTTP/2 client
• New stack walking API
• New reactive programming API
• Misc
Java Shell (JShell)
• Provides a read-eval-print-loop (REPL) shell for the
Java platform
• Provides a playground for the Java language and its
supporting APIs
• Provided by the jshell tool part of the JDK installation
New process API
• Before Java 9 ….
Process p = Runtime.getRuntime().exec("cmd /c notepad");
ProcessBuilder pb = new ProcessBuilder("cmd", "/c", “notepad");
Process p = pb.start();
New process API
• Limited support for process handling up to JDK 9
• Mostly for creation of a process …
New process API
• java.lang.Process extended with new methods
• New Java.lang.ProcessHandle class for process
management in a streamlike manner
onExit()
supportsNormalTermination()
toHandle()
children()
descendants()
pid()
info()
Small language enhancements
• Not really many … (var definitions did not make it
in Java 9)
• A few very minor enhancements part of project
Coin (the most significant being private methods
in interfaces)
G1 GC
• Replaces parallel GC as the default GC
• A low-pause collector
• Sacrifyes higher throughput
(… targets to provide better experience for users)
G1 GC
• The unit of work is a heap region in a generation
• Provides new framework for further optimizations
• Most other GCs work on generations directly
G1 GC
• Targets to clear as much garbage as possible
• Has larger footprint than parallel GC
HTTP/2 client
• Still in incubation (although part of release)
• Provides support for HTTP 2.0
Stack walking API
• new API for easier manipulation of stack traces
• Provided by the java.lang.Stackwalker class
Reactive programming API
• New publish-subscribe API
• Provided by the java.util.concurrent.Flow interface
Misc
• New collection factory methods
Set.of(…)
Map.of(…)
Map.ofEntries(…)
List.of(…)
Misc
• Multirelease JAR files
• Compact strings
• Variable handles
Misc
• A number of TLS enhancements
• Javadoc enhancements
• A number of others …
Java 9: the good partsdemo
Summary
• The new module system is beyond doubt the
most significant feature of JDK 9
• There are many new APIs in JDK 9 that extend
the developer’s toolbox
References
New features in Java 9
https://docs.oracle.com/javase/9/whatsnew/
Project Jigsaw
http://openjdk.java.net/projects/jigsaw/
Oracle JDK 9 Documentation Early Access
https://docs.oracle.com/javase/9/javase-docs.htm
References
JShell tutorial
http://cr.openjdk.java.net/~rfield/tutorial/JShellTut
orial.html
Java 9 Process API: The Shape of Things to Come
http://iteratrlearning.com/java/2017/03/12/java9-
process-api.html
References
Process API – Java 9
https://blog.oio.de/2016/09/02/process-api-java-9/
JDK 9 early access download
http://jdk.java.net/9/
Java 9: The (G1) GC Awakens
https://www.slideshare.net/MonicaBeckwith/java-9-the-
g1-gc-awakens

Java 9 sneak peek

  • 1.
  • 2.
    Who am I Softwareconsultant (CoffeeCupConsulting) BG JUG board member (http://jug.bg) OpenJDK and Oracle RBDMS enthusiast Twitter: @martin_fmi
  • 3.
    Agenda • Java 9:module system • Networking break • Java 9: the good parts
  • 4.
  • 5.
    Goals • Break themonolith JDK into smaller modules • Provide module system for Java applications java.base java.logging java.xml java.sql
  • 6.
    Supporting work … •JDK 8 compact profiles javac -profile <profile_name> compact 1 compact 2 compact 3
  • 7.
    Module metadata • Providedby module-info.java • Extends the syntax of the Java language • Exposed at runtime via the java.lang.Module class
  • 8.
    Module metadata module application.demo{ requires java.logging; requires banking.server; provides bg.jug.banking.server.applications.BankingApplication with bg.jug.banking.app.demo.DemoApplication; } Module module = object.getClass().getModule();
  • 9.
    Java 9: modulesystemdemo
  • 10.
    Java 9: thegood parts
  • 11.
    Sneak peek • JavaShell (JShell) • New process API • Small language enhancements • G1 as the default garbage collector
  • 12.
    Sneak peek • NewHTTP/2 client • New stack walking API • New reactive programming API • Misc
  • 13.
    Java Shell (JShell) •Provides a read-eval-print-loop (REPL) shell for the Java platform • Provides a playground for the Java language and its supporting APIs • Provided by the jshell tool part of the JDK installation
  • 14.
    New process API •Before Java 9 …. Process p = Runtime.getRuntime().exec("cmd /c notepad"); ProcessBuilder pb = new ProcessBuilder("cmd", "/c", “notepad"); Process p = pb.start();
  • 15.
    New process API •Limited support for process handling up to JDK 9 • Mostly for creation of a process …
  • 16.
    New process API •java.lang.Process extended with new methods • New Java.lang.ProcessHandle class for process management in a streamlike manner onExit() supportsNormalTermination() toHandle() children() descendants() pid() info()
  • 17.
    Small language enhancements •Not really many … (var definitions did not make it in Java 9) • A few very minor enhancements part of project Coin (the most significant being private methods in interfaces)
  • 18.
    G1 GC • Replacesparallel GC as the default GC • A low-pause collector • Sacrifyes higher throughput (… targets to provide better experience for users)
  • 19.
    G1 GC • Theunit of work is a heap region in a generation • Provides new framework for further optimizations • Most other GCs work on generations directly
  • 20.
    G1 GC • Targetsto clear as much garbage as possible • Has larger footprint than parallel GC
  • 21.
    HTTP/2 client • Stillin incubation (although part of release) • Provides support for HTTP 2.0
  • 22.
    Stack walking API •new API for easier manipulation of stack traces • Provided by the java.lang.Stackwalker class
  • 23.
    Reactive programming API •New publish-subscribe API • Provided by the java.util.concurrent.Flow interface
  • 24.
    Misc • New collectionfactory methods Set.of(…) Map.of(…) Map.ofEntries(…) List.of(…)
  • 25.
    Misc • Multirelease JARfiles • Compact strings • Variable handles
  • 26.
    Misc • A numberof TLS enhancements • Javadoc enhancements • A number of others …
  • 27.
    Java 9: thegood partsdemo
  • 28.
    Summary • The newmodule system is beyond doubt the most significant feature of JDK 9 • There are many new APIs in JDK 9 that extend the developer’s toolbox
  • 29.
    References New features inJava 9 https://docs.oracle.com/javase/9/whatsnew/ Project Jigsaw http://openjdk.java.net/projects/jigsaw/ Oracle JDK 9 Documentation Early Access https://docs.oracle.com/javase/9/javase-docs.htm
  • 30.
    References JShell tutorial http://cr.openjdk.java.net/~rfield/tutorial/JShellTut orial.html Java 9Process API: The Shape of Things to Come http://iteratrlearning.com/java/2017/03/12/java9- process-api.html
  • 31.
    References Process API –Java 9 https://blog.oio.de/2016/09/02/process-api-java-9/ JDK 9 early access download http://jdk.java.net/9/ Java 9: The (G1) GC Awakens https://www.slideshare.net/MonicaBeckwith/java-9-the- g1-gc-awakens