Java After Eleven

Developer Advocate

Java Team at Oracle

Lots to talk about

The plan for today:

  • start with a Java 11 code base

  • take it all the way to Java 19
    (and beyond)

  • be amazed by how much changes

This talk is:

  • a showcase, not a tutorial

  • not a complete list

  • created with the lavish help
    of the people in Twitch chat

Java 11

  • released 09/2018

  • free support by Oracle ended 01/2019

  • free community support until 10/2024

  • more free and commercial support available

It’s a great release…​

  • first "modern" Java release with LTS

  • solid feature set

  • stable

  • great support

…​but better things are waiting

Java 11 misses out on many recent developments:

  • thrilling new language features

  • some improved APIs

  • a few new JVM features

  • improved performance

Curious?

Let me show you how much
you’re missing out on
if you’re (still?) on Java 11.

Code

Code, code, code, code

Java 12

What we’ve seen:

  • more powerful collections | Collectors::teeing

  • better async error handling | ↴
    CompletableFuture::exceptionallyCompose

Java 12

What we haven’t seen:

  • transforming Strings | ↴
    String.transform(Function<String, R>)

  • social media number format | ↴
    NumberFormat::getCompactNumberInstance

  • easy file comparison | Files::mismatch

  • included JDK CDS archive

Java 13

What we haven’t seen:

  • automatic application CDS archive

Java 14

What we’ve seen:

  • switch expressions | ↴

    boolean bool = switch (ternaryBool) {
    	case TRUE -> true;
    	case FALSE -> false;
    	case FILE_NOT_FOUND -> throw
    			new FileNotFoundException("🤬");
    };
  • helpful NPE messages

Java 14

What we haven’t seen:

  • JFR event streaming

Java 15

What we’ve seen:

  • text blocks | ↴

    var recommendation = """
    		{
    			"title": '$TITLE',
    			"recommendations": $RECS
    		}
    	""";
  • obvious String formatting | String::format

Java 15

What we haven’t seen:

  • hidden classes

Java 16

What we’ve seen:

  • records | record Title(String text)

  • type patterns | o instanceof Article a

  • Stream::toList

Java 16

What we haven’t seen:

  • improvements to Stream and HTTP/2 client

  • Unix domain socket support

  • OS-specific installers | jpackage

Java 17

What we’ve seen:

  • sealed clases | sealed class …​ permits

  • enhanced pseudo-random number generator API | ↴
    RandomGenerator and RandomGeneratorFactory

Java 17

What we haven’t seen:

  • always-strict floating-point semantics

Java 17

What we’ve seen a bit:

  • better performance characteristics

All following diagrams come
from Stefan Johansson's post
GC progress from JDK 8 to JDK 17.

Java 18

What we’ve seen:

  • JavaDoc code snippets (better)

  • jwebserver

  • UTF-8 by default

Java 18

What we haven’t seen:

  • Internet resolution SPI

Java 19

Previews galore!

Java Next

What we’ve seen:

  • pattern matching in switch | ↴

    return switch (post) {
    	case Article article -> article.repository();
    	case Video video -> video.repository();
    	default -> Optional.empty();
    };
  • record patterns | ↴

    case Article(var repository) -> repository;

Java Next

What we’ve seen:

  • virtual threads + structured concurrency | ↴

    try (var scope = new StructuredTaskScope
    		.ShutdownOnFailure()) {
    	// ...
    
    	scope.join();
    	scope.throwIfFailed();
    } catch (/* ... */) {
    	// ...
    }

Java Next

What we haven’t seen

Java 11 to 19+

  • more expressive code | LOC: 2061 📉 1663

  • faster code | run time: ~ 1.1 s 📉 ~ 0.9 s

  • better JVM | GCs, packaging, monitoring, etc.

  • better tooling | JFR, JavaDoc, jwebserver, etc.

Sure you don’t want to upgrade?

So long…​

37% off with
code fccparlog

bit.ly/the-jms

More

Slides at slides.nipafx.dev
⇜ Get my book!

Follow Nicolai

nipafx.dev
/nipafx

Follow Java

inside.java // dev.java
/java    //    /openjdk

Image Credits