Java After Eight

Lots to talk about

The plan for today:

  • start with a Java 8 code base

  • take it all the way to Java 14

  • be amazed by how much changes

This talk is:

  • a showcase, not a tutorial

  • not a complete list

Java 8

  • released 03/2014

  • free support by Oracle ended 01/2019

  • free support by Red Hat until 06/2023

  • more free and commercial support available

It’s a great release…​

  • solid feature set

  • good performance

  • very stable

  • occasional backports

  • great support

…​but it’s getting dated

Java 8 misses out on most recent developments:

  • many new language features

  • many new and improved APIs

  • many new JVM features

  • improved performance
    (in certain cases)

Time to upgrade

Let me show you how much
you’re missing out on
if you’re still on Java 8.

Code

Code, code, code, code

Java 9

  • released 09/2017

  • support ended 01/2018

What we’ve seen

  • module system | module-info.java

  • collection factories | List::of

  • new process API | ProcessHandle::pid

  • new version API | Version::major

  • improved streams | Stream::dropWhile

  • improved Optional | Optional::or

What we haven’t seen

  • try with effectively final resource

  • private interface methods

  • stack walking API (improves logging perf)

  • unified logging

  • multi-release JARs

  • app/runtime images | jlink

Java 10

  • released 03/2018

  • support ended 07/2018

What we’ve seen

  • local-variable type inference | var tags

  • more collection factories | Map::copyOf

  • more collectors | Collectors::toUnmodifiableList

What we haven’t seen

  • application class-data sharing

Java 11

  • released 09/2018

  • free support by Oracle ended 01/2019

  • free support by Red Hat until 10/2024

  • commercial support available

What we’ve seen

  • improved whitespace handling | String::strip

  • uniform array creation | toArray(String[]::new)

  • better Path creation | Path::of

  • better Predicate negation | Predicate::not

What we haven’t seen

  • reactive HTTP/2 API | ↴

    HttpRequest request = HttpRequest.newBuilder()
        .GET()
        .uri(URI.create("http://codefx.org"))
        .header("Accept-Language", "en-US,en;q=0.5")
        .build();
  • more String improvements | String::lines

  • easier IO | Files::readString

  • improved Optional | Optional::isEmpty

  • Java scripts | java SourceFile.java

Java 12

  • release 03/2019

  • support ended 07/2019

What we’ve seen

  • more powerful collections | Collectors::teeing

  • better async error handling | ↴
    CompletableFuture::exceptionallyCompose

What we haven’t seen

  • switch expressions | ↴

    boolean bool = switch (ternaryBool) {
    	case TRUE -> true;
    	case FALSE -> false;
    	case FILE_NOT_FOUND -> throw
    			new FileNotFoundException("🤬");
    };
  • transforming Strings | ↴
    String.transform(Function<String, R>)

  • social media number format | ↴
    NumberFormat::getCompactNumberInstance

  • easy file comparison | Files::mismatch

  • included JDK CDS archive

Java 13

  • released 09/2019

  • free support ended 01/2020

  • commercial support available by Azul

What we’ve seen

  • text blocks | ↴

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

What we haven’t seen

  • automatic application CDS archive

Java 14

  • release 03/2020

  • support ends 07/2020

What we’ve seen

  • records | record Title(String text)

  • pattern matching | o instanceof Article a

  • helpful NPE messages

What we haven’t seen

  • standardized foreign-memory access

  • JFR event streaming

  • OS-specific installers | jpackage

Java 8 to 14

  • stronger encapsulation and better services | modules

  • safer code | processes, versions, whitespace, etc.

  • more expressive code | LOC: 1654 📉 1242

  • faster code | run time: ~1s 📉 ~ 0.8 ms

  • better JVM | MR-JARs, GCs, packaging, monitoring, etc.

Sure you don’t want to upgrade?

About Nicolai Parlog

37% off with
code fccparlog

tiny.cc/jms

Follow

Want More?

⇜ Get my book!

You can hire me:

  • training (Java 8-14, JUnit 5)

  • consulting (Java 8-14)

Image Credits