Upgrade to Pro — share decks privately, control downloads, hide ads and more …

9 Lives of Java 9

Tomasz Borek
December 18, 2016

9 Lives of Java 9

Not a simple "what's new", since I'm also examining history of the language, trying to show what led to current state and Jigsaw being necessary.

This includes new announcements about JDK 18.03, JDK10, new Java release cadence, Java EE and all recent (and not so recent) highlights showing I was right speaking about Java transition.

If time permits, there's also trivia game and demo.

Tomasz Borek

December 18, 2016
Tweet

More Decks by Tomasz Borek

Other Decks in Technology

Transcript

  1. Currently • Kraków • Newbies or juniors • 3-5 months

    • To programmers • Or as close as I can • With JS, QA, etc. • 4th edition Nov 2017
  2. Green project • The Green Team • Smart appliances •

    C++ extension → Oak → Green Platform (and OS)→ Java • Star 7 (summer 1992)
  3. Ends because... • Too much control in hands of the

    users – Cable TV industry wants dumber remotes • PDAs didn’t quite took off • Instead, World Wide Web did – Hence, WebRunner → HotJava, browser – Appropriate interactivity – 1994 – retargeting to WWW – 1995 – HotJava – 1996...
  4. WORA • JIT (Just In Time) compiler for Windows •

    Network byte order • So, all that to run C code?
  5. JDK 1.02, first Java • AWT event model • Inner

    classes • JavaBeans • JDBC • RMI • Reflection (introspection only, TBH) • GC • VM • MCM (green threads) • Sandbox February 19, 1997
  6. Playground • Tripled in size • Introduced JCF • strictfp

    keyword • Swing graphical API • Sun’s JVM had a JIT compiler now • Java plug-in
  7. Enterprise • Lovely Sun marketing – SE, ME, EE •

    Enterprise rulz – J2EE :-) • EJBOSS • Standards are hard • Desktop? Forget it!
  8. Spreading the wings • Kestrel (1.3, right) – improvements everywhere

    (PermGen, HotSpot JVM). JNDI and JPDA though! • Merlin had APIs and libs: NIO, JAXP, Logging, JDBC 3, Preferences, Ipv6, RegEx, Images. Plus Java Web Start, assert and chaining exceptions.
  9. Tiger • Majority of interview questions – Next big thing

    is JDK8 • Enum, annotations, generics, foreach, varargs, auto-/un- boxing, concurrency, scanner... • Improved JMCM!
  10. Mustang and Dolphin • Invokedynamic • 64bit pointers • Coin

    • 8 and 9 • perf • JVM perf • GUI (Swing) • javac, JDBC 4, JAXB 2 http://openjdk.java.net/projects/coin/
  11. So, JDK 8 JEPS? 55 all together GA on 14th

    March 2014 Maurice Naftalin Lambda FAQ
  12. Project λ • Functions are first-class citizens (almost) – Anonymous

    classes still but – Function interface – @FunctionalInterface • Method refs • Change your thinking • Immutability, effectively final vars • Coupled with streams
  13. Project λ + Streams • Functions are first-class citizens (almost)

    – Anonymous classes still but – Function interface – @FunctionalInterface • Method refs • Change your thinking • Immutability, effectively final vars • Coupled with streams
  14. So, JDK 9 JEPS? 91 all together GA on 21st

    September 2017 lafk.pl/jdk9-on-jdd/
  15. Project Kulla = JShell • 222: jshell – the Java

    shell (REPL) • Kulla – builder god, banished when done • https://docs.oracle.com/javase/9/tools/jshell.htm • /aCommand → /exit /help intro /help shortcuts • /list • /save • /open some-jshell-file.jsh
  16. Project Kulla = JShell • 222: jshell – the Java

    shell (REPL) • Features Tab-completion, quite nice at that! • Jline uses C readline lib • Look for ~/.inputrc or /etc/input.rc
  17. Project Jigsaw • JAR hell, classpath loading problems • JARs

    are not components, they are files • JDK and most Java apps are monoliths • JDK weighs a lot • Your Java app weighs a lot • µservices aren’t monolithic (shouldn’t be!) • Game changers!
  18. Project Jigsaw • Rabea Gransberger – refactor to modules •

    Mark Reinhold – State of the modules system – http://openjdk.java.net/projects/jigsaw/spec/sotms/ – Java One sessions • My own 9 Lives of Java 9 – https://github.com/LIttleAncientForestKami/j9-intro • http://openjdk.java.net/projects/jigsaw
  19. Project Jigsaw - JEPs • 162: Prepare for Modularisation •

    200: The Modular JDK • 201: Modular Source Code (Jigsaw itself) • 220: Modular Run-Time images – Standard class libraries modularised (rt.jar) – Files more efficient than JAR • 260: Most internal APIs now encapsulated – Unsafe, VarHandles, MethodHandles • 275: java packager • 282: jlink, Java linker 7 in total
  20. Modules in a nutshell • Base always present • Requires

    – modules you need • Exports – what you publish (here public matters) • Use – required services – via ServiceLoader • http://cr.openjdk.java.net/~mr/jigsaw/jdk9-module-summary.html • https://bugs.openjdk.java.net/secure/attachment/72525/jdk.png • module-info.java, module path • jlink, jdepend • https://github.com/accso/java9-jigsaw-depvis
  21. Default GC is G1 • JEP 248 • CMS deprecated

    – ParNew as well • Regions, categorized • Huge objects • JEPs: – 250: Strings in CDSes – 214: remove deprecated combinations • Not for small heaps • String Deduplication – JEP 192, 8u20
  22. Unicode, Javadoc, Nashorn • 221: Simplified Doclet API • 224:

    HTML5 Javadoc • 225: Javadoc Search • 226: UTF-8 Property Files • 267: Unicode 8.0 (7,3k+) • 227: Unicode 7.0 (2,8k+) • 236: Parser API for Nashorn • 252: Use CLDR Locale Data by Default • 292: Implement Selected ECMAScript 6 Features in Nashorn 9 in total
  23. JEP 266: More concurrent updates • java.util.concurrent.Flow – Reactive programming

    – http://www.reactive-streams.org/ - de-facto standard – PubSub: • CompleteableFuture (20 or so changes) – http://www.baeldung.com/java-9-completablefuture
  24. Things will be removed! • 277: Enhanced Deprecation • 289:

    Deprecate the Applet API – forRemoval set to false • 214: Remove GC Combinations Deprecated in JDK 8 • 231: Remove Launch-Time JRE Version Selection • 240: Remove the JVM TI hprof Agent • 241: Remove the jhat Tool • 298: Remove Demos and Samples 5 in total
  25. Security • 219: Datagram Transport Layer Security (DTLS) • 229:

    Create PKCS12 Keystores by Default • 244: TLS Application-Layer Protocol Negotiation Extension • 249: OCSP Stapling for TLS • 273: DRBG-Based SecureRandom Implementations • 287: SHA-3 Hash Algorithms • 288: Disable SHA-1 Certificates • 290: Filter Incoming Serialization Data 8 in total Another 8 in perf
  26. Libraries changes • 255: Merge Selected Xerces 2.11.0 Updates into

    JAXP • 259: Stack-Walking API • 260: Encapsulate Most Internal APIs • 266: More Concurrent Updates • 269: Convenience Factory Methods for Collections 5 selected
  27. JVM changes • 193: Variable Handles • 245: Validate JVM

    Command-Line Flag Arguments • 228: Add More Diagnostic Commands • 238: Multi-Release JAR Files • 247: Compile for Older Platform Versions • 223: New Version-String Scheme • 217: Annotations Pipeline 2.0 • 280: Indify String Concatenation • 272: Platform-Specific Desktop Features Whopping 32 in total • 233: Generate Run-Time Compiler Tests Automatically • 235: Test Class-File Attributes Generated by javac • 211: Elide Deprecation Warnings on Import Statements • 212: Resolve Lint and Doclint Warnings • 216: Process Import Statements Correctly • 279: Improve Test-Failure Troubleshooting • 281: HotSpot C++ Unit-Test Framework • 284: New HotSpot Build System • 248: Make G1 the Default Garbage Collector • 278: Additional Tests for Humongous Objects in G1 • 243: Java-Level JVM Compiler Interface • 270: Reserved Stack Areas for Critical Sections • 274: Enhanced Method Handles • 237: Linux/AArch64 Port • 158: Unified JVM Logging • 264: Platform Logging API and Service • 271: Unified GC Logging • 165: Compiler Control
  28. So...? • Jigsaw and modularity – Image, modules, JAR replace,

    linking, deps finding • JVM – tooling, ground work (CLI, GC, String indify), • APIs – JShell, Stack Walking, Process, Flow • Performance, Security • Why?
  29. In short • Java went like a river, changing directions

    – Smart appliances → net → EE → SE → FP – Devs see language changes, but there’s more • IoT, Big Data, Cloud (hence: FP, modularity) • Jigsaw is the theme, but foundations improved! – JDK, perf, Strings, compiler, GC, tooling – Stack, Process, Jshell, Xerces, Flow
  30. Java EE – Not J2EE, not anymore • Waited for

    JDK9 and Jigsaw • Folks moved ahead though (without Oracle) – EE Guardians (https://javaee-guardians.io/) – MicroProfile (http://microprofile.io/) – Spring and container/server vendors • Good summary – https://www.infoq.com/news/2017/04/long-road-for-java-ee-8 • Donated to Eclipse Foundation!
  31. 9 Lives of Java 9 @LAFK_pl Now it will move

    faster! 4 remain! Consultant @
  32. Java 18.03 • Every quarter (first month): bug fixes and

    patches • Every March – feature release • Every September – LTS feature release – LTS – 3 years • https://mreinhold.org/blog/forward-faster
  33. JDK 10 JEPs • 286: Local-Variable Type Inference • 296:

    Consolidate the JDK Forest into a Single Repository • 304: Garbage-Collector Interface • 307: Parallel Full GC for G1 • 310: Application Class-Data Sharing • 312: Thread-Local Handshakes • 313: Remove the Native-Header Generation Tool (javah) • 314: Additional Unicode Language-Tag Extensions • 316: Heap Allocation on Alternative Memory Devices • 317: Experimental Java-Based JIT Compiler • 319: Root Certificates • 322: Time-Based Release Versioning http://openjdk.java.net/projects/jdk/10/#Schedule
  34. Minor JDK10 JEPs • 286: Local-Variable Type Inference • 296:

    Consolidate the JDK Forest into a Single Repository • 304: Garbage-Collector Interface • 307: Parallel Full GC for G1 • 310: Application Class-Data Sharing • 312: Thread-Local Handshakes • 313: Remove the Native-Header Generation Tool (javah) • 314: Additional Unicode Language-Tag Extensions • 316: Heap Allocation on Alternative Memory Devices • 317: Experimental Java-Based JIT Compiler • 319: Root Certificates • 322: Time-Based Release Versioning http://openjdk.java.net/projects/jdk/10/#Schedule
  35. GC JDK10 JEPs • 286: Local-Variable Type Inference • 296:

    Consolidate the JDK Forest into a Single Repository • 304: Garbage-Collector Interface • 307: Parallel Full GC for G1 • 310: Application Class-Data Sharing • 312: Thread-Local Handshakes • 313: Remove the Native-Header Generation Tool (javah) • 314: Additional Unicode Language-Tag Extensions • 316: Heap Allocation on Alternative Memory Devices • 317: Experimental Java-Based JIT Compiler • 319: Root Certificates • 322: Time-Based Release Versioning http://openjdk.java.net/projects/jdk/10/#Schedule
  36. GC JDK10 JEPs • 304: Garbage-Collector Interface • 307: Parallel

    Full GC for G1 • 316: Heap Allocation on Alternative Memory Devices – -XX:AllocateHeapAt=<path> – NVDIMM, non-DRAM with DRAM semantics – Lower priority, larger capacity (than DRAM)
  37. GC JDK10 JEPs • 304: Garbage-Collector Interface • 307: Parallel

    Full GC for G1 – -XX:ParallelGCThreads=<nr> – Affects Young and Mixed – ParallelGC has parallel full GC, so G1 should too • Now it’s single threaded • 316: Heap Allocation on Alternative Memory Devices
  38. GC JDK10 JEPs • 304: Garbage-Collector Interface – Core reorganization

    – In future: Epsilon • 307: Parallel Full GC for G1 • 316: Heap Allocation on Alternative Memory Devices
  39. JDK 10 minor JEPs • 296: Consolidate the JDK Forest

    into a Single Repository • 310: Application Class-Data Sharing • 313: Remove the Native-Header Generation Tool (javah) • 314: Additional Unicode Language-Tag Extensions • 319: Root Certificates • 322: Time-Based Release Versioning
  40. JEP-310: AppCDS • Since Tiger we can share class data

    (CDS) – Only null class loader – Set of classes → mem-mapped archive – Such archive can be shared across JVMs • AppCDS: – System class loader (and custom ones) – java -Xshare:off -XX:+UseAppCDS -XX:DumpLoadedClassList=hello.lst -cp hello.jar HelloWorld
  41. JEP-313: remove javah • javah generates native header • No

    longer used in JDK or during builds • javac (since JDK8) can write native header files (during compilation) • javac has API access through Compiler API or java.util.spi.ToolProvider – javah does not • Ergo - removal
  42. JDK 10 minor JEPs • 296: Consolidate the JDK Forest

    into a Single Repository • 310: Application Class-Data Sharing • 313: Remove the Native-Header Generation Tool (javah) • 314: Additional Unicode Language-Tag Extensions • 319: Root Certificates • 322: Time-Based Release Versioning
  43. JEP-319: root certificates • Root cacerts keystore should have root

    certs • OpenJDK cacerts store is empty • Oracle JDK is not • This JEP makes 17 companies that signed OCA open-source their root certs – TLS works from the start with it http://openjdk.java.net/jeps/319
  44. Version string ➜ ~ /usr/lib/jvm/java-9-openjdk-amd64/bin/java -version openjdk version "9-internal" OpenJDK

    Runtime Environment (build 9-internal+0-2016-04-14- 195246.buildd.src) OpenJDK 64-Bit Server VM (build 9-internal+0-2016-04-14- 195246.buildd.src, mixed mode) ➜ ~ java -version java version "1.8.0_101" Java(TM) SE Runtime Environment (build 1.8.0_101-b13) Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)
  45. Version string after JEP-223 // JDK 9, build 165, early

    access ➜ /tmp/jdk-9/bin/java -version java version "9-ea" Java(TM) SE Runtime Environment (build 9- ea+165) Java HotSpot(TM) 64-Bit Server VM (build 9- ea+165, mixed mode)
  46. Version string after JEP-322 //build 13 JDK 10.0.1 $ java

    --version openjdk 10.0.1 2018-04-19 OpenJDK Runtime Environment (build 10.0.1+13) OpenJDK 64-Bit Server VM (build 10.0.1+13, mixed mode) //build 42 JDK 11 LTS $ java --version openjdk 11 2018-09-20 LTS OpenJDK Runtime Environment (build 11+42-LTS) OpenJDK 64-Bit Server VM (build 11+42-LTS, mixed mode)
  47. Exciting JDK 10 JEPs • 286: Local-Variable Type Inference •

    296: Consolidate the JDK Forest into a Single Repository • 304: Garbage-Collector Interface • 307: Parallel Full GC for G1 • 310: Application Class-Data Sharing • 312: Thread-Local Handshakes • 313: Remove the Native-Header Generation Tool (javah) • 314: Additional Unicode Language-Tag Extensions • 316: Heap Allocation on Alternative Memory Devices • 317: Experimental Java-Based JIT Compiler • 319: Root Certificates • 322: Time-Based Release Versioning http://openjdk.java.net/projects/jdk/10/#Schedule
  48. Exciting JDK 10 JEPs • 286: Local-Variable Type Inference –

    var list = new ArrayList<String>(); • // infers ArrayList<String> – var stream = list.stream(); • // infers Stream<String> – Only in for loops (both) and method locals • 312: Thread-Local Handshakes – Inspect one thread at a time, less ‘safepointing’ • 317: Experimental Java-Based JIT Compiler – Graal, JIT done in Java, works on ASTs http://openjdk.java.net/projects/jdk/10/#Schedule
  49. In short • Java went like a river, changing directions

    – Smart appliances → net → EE → SE → FP – You see where language changes, but there’s more • IoT, Big Data, Cloud (hence: FP, modularity) • Jigsaw is the theme, but foundations improved! • Transition has only began! JDK10, 11…
  50. 9 Lives of Java 9 @LAFK_pl 21st September 2017 GA

    March 2018 JDK 10! At least 4 remain! Consultant @