boolean bool = switch (ternaryBool) {
case TRUE -> true;
case FALSE -> false;
case FILE_NOT_FOUND -> throw
new FileNotFoundException("🤬");
};
The plan for today:
start with a Java 11 code base
take it all the way to Java 17
(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
slides at slides.nipafx.dev
code at github.com/nipafx
demo code base: /java-after-eight
more Java 9+ features: /demo-java-x
Tweet questions with #JavaNext. I’ll answer—live!
released 09/2018
free support by Oracle ended 01/2019
free community support until 10/2024
more free and commercial support available
first "modern" Java release with LTS
solid feature set
stable
great support
Java 11 misses out on many recent developments:
thrilling new language features
some improved APIs
a few new JVM features
improved performance
Let me show you how much
you’re missing out on
if you’re (still?) on Java 11.
Code, code, code, code
What we’ve seen:
more powerful collections | Collectors::teeing
better async error handling | ↴
CompletableFuture::exceptionallyCompose
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
What we haven’t seen:
automatic application CDS archive
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
What we haven’t seen:
JFR event streaming
What we’ve seen:
text blocks | ↴
var recommendation = """
{
"title": '$TITLE',
"recommendations": $RECS
}
""";
obvious String
formatting | String::format
What we haven’t seen:
hidden classes
What we’ve seen:
records | record Title(String text)
type patterns | o instanceof Article a
Stream::toList
What we haven’t seen:
improvements to Stream and HTTP/2 client
Unix domain socket support
OS-specific installers | jpackage
What we’ve seen:
sealed clases | sealed class … permits
enhanced pseudo-random number generator API | ↴
RandomGenerator
and RandomGeneratorFactory
What we haven’t seen:
always-strict floating-point semantics
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.
What we’ve seen:
pattern matching in switch
| ↴
return switch (post) {
case Article article -> article.repository();
case Video video -> video.repository();
default -> Optional.empty();
};
What we haven’t seen
vector API | Project Panama
foreign code and memory | Project Panama
inline classes | Project Valhalla
virtual threads | Project Loom
more expressive code | LOC: 2051 📉 1626
faster code | run time: ~ 1.1 s 📉 ~ 1 s
better JVM | GCs, packaging, monitoring, etc.
Sure you don’t want to upgrade?