HttpRequest request = HttpRequest.newBuilder()
.GET()
.uri(URI.create("http://codefx.org"))
.header("Accept-Language", "en-US,en;q=0.5")
.build();
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
slides at slides.codefx.org
code at github.com/CodeFx-org
demo code base: /java-after-eight
more Java 9+ features: /demo-java-x
released 03/2014
free support by Oracle ended 01/2019
free support by Red Hat until 06/2023
more free and commercial support available
solid feature set
good performance
very stable
occasional backports
great support
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)
Let me show you how much
you’re missing out on
if you’re still on Java 8.
Code, code, code, code
released 09/2017
support ended 01/2018
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
try
with effectively final resource
private interface methods
stack walking API (improves logging perf)
unified logging
multi-release JARs
app/runtime images | jlink
released 03/2018
support ended 07/2018
local-variable type inference | var tags
more collection factories | Map::copyOf
more collectors | Collectors::toUnmodifiableList
application class-data sharing
released 09/2018
free support by Oracle ended 01/2019
free support by Red Hat until 10/2024
commercial support available
improved whitespace handling | String::strip
uniform array creation | toArray(String[]::new)
better Path
creation | Path::of
better Predicate
negation | Predicate::not
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
release 03/2019
support ended 07/2019
more powerful collections | Collectors::teeing
better async error handling | ↴
CompletableFuture::exceptionallyCompose
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
released 09/2019
free support ended 01/2020
commercial support available by Azul
text blocks | ↴
var recommendation = """
{
"title": '$TITLE',
"recommendations": $RECS
}
""";
obvious String
formattting | String::format
automatic application CDS archive
release 03/2020
support ends 07/2020
records | record Title(String text)
pattern matching | o instanceof Article a
helpful NPE messages
standardized foreign-memory access
JFR event streaming
OS-specific installers | jpackage
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?
💻 codefx.org
🐦 @nipafx
Slides at slides.codefx.org
⇜ Get my book!
You can hire me:
training (Java 8-14, JUnit 5)
consulting (Java 8-14)