Course Description

Overall Narrative: Discuss Java 8’s capabilities (& limitations) and answer the question “Does the arrival of streams make Java 8 a functional language?”. Then discuss Java 8 concurrency in some detail.



1 Day


Target Audience

Experienced and advanced Java programmers. Especially suitable for architects and team leaders who want to learn the limits of Java 8 or work out whether the time is right for them to move to Java 9. Also suitable for teams trying to decide whether to stick with Java or move to e.g. Kotlin or Scala.


Course Prerequisites

Attendees must already be experienced Java 8 programmers, and comfortable working with lambdas and the Streams API. Any wider knowledge of Functional Programming concepts is very helpful but not essential. Any experience programming in Scala, Clojure, Kotlin or Haskell will be an advantage.


Software Spec and Set-up Requirements:


A laptop with a Java 9 installation, Maven 3.5 or above and a Java IDE (Eclipse Oxygen, IntelliJ 2017.3 or Netbeans 9) that supports Java 9


A laptop with a Java 8 installation, Maven 3 and a Java IDE (Eclipse, IntelliJ or Netbeans 9) AND a setup to use Java 9 from the command line (e.g. VirtualBox Linux VM or Docker container)


Course Content

A. Functional Programming in Java 8

1. Motivation

  •   Streams enable “slightly functional programming” – graphics
  •   What is functional programming?
  •   7 features of FPL
  •   How far does Java go?

2. Values and Function Objects

  •   2 types of values
  •   Function objects
  •   Internals / oops & tie to Runnables & SAM types

3. FP in Java from first principles (mostly IDE, no Java 8 syntax)

  •   Building up FP in Java
  •   A function type
  •   Apply & compose
  •   Making it generic
  •   Lambda syntax

Lab: Building up FP in Java

4. Functional Collections and Streams

  •   Problems – internal mutation
  •   The need for a new abstraction – Streams
  •   Streams are not first-class
  •   Streams as “container types”
  •   Building the pipeline
  •   Problems with Stream programming

Lab: Advanced Streams

5. Default methods

  •   Why we need them
  •   How they work
  •   IDE: Practical considerations
  •   Stateless traits vs interface evolution
  •   Java 8 features in context of other languages
  •   Conservative language design
  •   Lambdas are not inner classes (invokedynamic)

B. Java 8 Concurrency Updates

6. Parallel Streams

  •   Moving beyond external iteration
  •   Fork / Join
  •   Implementation details
  •   Shortcomings

Lab: Parallel Streams

7. CompleteableFuture

  •   Review of Java 5 Futures
  •   Futures and Promises
  •   CompleteableFuture
  •   CF as a “container type”

Lab: CompleteableFuture

8. Misc Concurrency Updates

  •   ConcurrentHashMap in Java 7 and 8
  •   CountdownLatch, CyclicBarrier and Phaser
  •   Adders and Accumulators
  •   Missing Methods on Map

C. Introduction to Java 9

9. New Version Scheme and Roadmap

  •   History of OpenJDK
  •   New Release Scheme and Process
  •   Long-Term Support Releases
  •   Non-Oracle Vendors
  •   Java on Docker

10. Modules

  •   Design (pros and cons)
  •   Multi-Release JARs
  •   Maven
  •   Greenfield deployments
  •   Using non-default modules
  •   Writing a first module
  •   Exporting and APIs

Lab: A first module

11. Collections and Streams Updates

  •   Collection helpers
  •   Reactive Streams
  •   Flow, Publisher, Subscriber
  •   Transformations and Processors

Lab: Using Flows

12. Internal Changes

  •   Encapsulation
  •   Unsafe
  •   Compact Strings
  •   Indify String Concat
  •   AOT Compilation


See more Java courses