Real World Java 9
How is Java 9 going to change the way developers work?
Abstract
The feature we always hear about whenever Java 9 is in the news is Jigsaw, modularity. But this doesn’t scratch the same developer itch that Java 8’s lambdas and streams did, and we’re left with a vague sensation that the next version might not be that interesting.
Java 9 actually has a lot of great additions and changes to make development a bit nicer. These features can’t be lumped under an umbrella term like Java 8’s lambdas and streams, the changes are scattered throughout the APIs and language features that we regularly use.
In this presentation Trisha will show, via live coding:
- What the Java Platform Module System is and how to make your code modular
- The improvements to the Streams API that make it easier to control infinite streams
- How the Collections convenience methods simplify code
Along the way we’ll bump into other Java 9 features, including some of the additions to interfaces and Optional, and a number of other small changes that make coding in Java a bit nicer than it was before.
Videos
These are all the available videos, with the most recent at the top. Usually, the more recent the talk the more polished, therefore usually they’re better. With this talk, it’s more a case of showcasing / focusing on different aspects in different versions.
This JetBrains webinar is the most up-to-date version of the talk, and includes more Java 9 features than any of the others, including a quick look at JShell. It has almost no content on Reactive Streams though, so check out one of the other videos if this is what you’re interested in.
- vJUG, September 2017. Lucky to have 90 minutes to cover the material.
- GOTO Amsterdam. Less reactive streams, less Jigsaw, marginally more time for the “other” Java 9 features.
- J on the Beach, Malaga. Pretty much the same as the DevoxxUK version.
- DevoxxUK. More focus on Jigsaw / Java Modules.
- QCon London. Much more focus on Reactive Streams: what they are, how they work, and how to migrate an app to use the Reactive Streams API.
Slides
These are the latest slides. For earlier versions, see Slideshare.
Resources
The code for this presentation was originally created to demonstrate Java 8 code in Java 8 in Anger, take a look at the videos there to see more background on the application and how it used Java 8 Streams and Lambda Expressions for the core business logic. The code and the presentation evolved to include some Java 9 features.
I have another Java 9 talk based off this code, Anticipating Java 9 - Functionality and Tooling, which demos more individual Java 9 features and talks specifically about IntelliJ IDEA’s support for it.
Articles & More Detail
I’ve expanded upon the examples in this presentation in a couple of articles about adopting Java 9:
- Java Magazine: Migrating from Java 8 to Java 9
- InfoQ: Painlessly Migrating to Java Jigsaw Modules - a Case Study
- JetBrains Blog: Real World Java 9 Summary and FAQs in this blog post I answer audience questions about the module system mostly, some questions relate to other Java 9 features.
Code
- https://github.com/trishagee/sense-nine. The full application with all Java 9 code is currently under the working-system branch, the presentation builds off the code in start_point.
- Original Java 8 code comes from https://github.com/trishagee/sense, the master branch has the most up-to-date final working Java 8 application. JUnit 5 tests come from the junit-5 branch. Java 8 and 9 features live side-by-side in yow-brisbane. That app was built with Java build 9-ea+146, but does not work with build 9-ea+156
IntelliJ IDEA
The earliest version of this talk runs on IntelliJ IDEA 2017.1, which supports Jigsaw much better than pre-2017 versions. However, I’m currently using 2017.3 EAP, as this has the best support for Java 9/JPMS and also a basic version of the Java Console. Read a summary of the Java 9 support in IntelliJ IDEA.
For a 5-minute version of IntelliJ IDEA’s support for modularity, watch @jonnyzzz’s demo during the JavaOne Keynote.
Java 9
- Download Oracle’s JDK 9 or OpenJDK
- What’s New in Java 9
- Java 9 Expert Insights series of short videos
- JDK 9 Project Page
- Download JDK 9 EA
- What is cool in Java 8 and new in 9(Slides: Java 9 content starts at Slide 40)
- The Ultimate Guide to Java 9
- Inside Java 9 – Version Schema, Multi-Release JARs, and More
- Inside Java 9 – Performance, Compiler, and More
- Java 9’s other new enhancements, Part 2: Milling Project Coin
- Java Platform Standard Edition 9 Early Access Documentation
- Java 9 Javadoc (note the new search feature!)
Jigsaw / JPMS
- Project Jigsaw
- JEP 261: The Java Platform Module System
- Quick Start Tutorial
- The State of the Module System
- Project Jigsaw: The module system
- Programming with Modularity and Project Jigsaw. A Tutorial Using the Latest Early Access Build
- First steps with Java 9 and Project Jigsaw – Part 1
- First steps with Java 9 and Project Jigsaw – Part 2
- Java 9 modules - JPMS basics
- Java SE 9 - JPMS modules are not artifacts
- Java SE 9 - JPMS module naming
- Modules and javac
jlink
- jlink Reference Documentation
- Java 9 jlink Explained in 5 Minutes
- The Jigsaw Quick Start Tutorial also has a section on jlink
Migrating to Java 9 (and Jigsaw)
- Java 9 Migration Guide
- Migrating to Modules (video) Highly recommended.
- How Java 9 And Project Jigsaw May Break Your Code
- The Jigsaw “kill switch”
- jdeps Tool
Reactive Programming and RxJava
- Reactive Streams API
- Reactive Streams Implementations
- Reactive Programming with JDK 9 Flow API
- RxJava Documentation
- RXJava2 by Example
- RxJava 2.0 - Tutorial
- RxJava for easy concurrency and backpressure
- Multicasting in RxJava
- Reactive Streams, j.u.concurrent, & beyond! (video)
- Understanding Reactive Types
- Reactive Streams: Handling Data-Flow the Reactive Way(slides)
- RxMarbles
- Reactor by Example
Multi-Release JAR Files
Stack-Walking API
- JEP 259
- Deep Dive into the Stack-Walking API
- Java 9’s other new enhancements, Part 5: Stack-Walking API
Process API
- JEP 102
- Java 9’s other new enhancements, Part 3: The Process API
- Java 9 Process API: The Shape of Things to Come
JShell (the REPL)
HTML5 Javadoc
Other
- GoF - Adapter Pattern (required to adapt between Java 9 Flow API and the Reactive Streams API)