SlideShare a Scribd company logo
1 of 27
Java on speed
What’s new in Java 9, 10, 11, 12, 13 and 14?
arto.santala@solita.fi
Useful and coherent
examples on how to use
latest versions of Java
Just kidding.
There are none, so…
Lets just muck it up
1995
2020
19 years to Java 8
6 years from 8 to 15
New version ever 1.5 years
Brew some Java
brew tap AdoptOpenJDK/openjdk
brew search jdk
brew cask install adoptopenjdk9
brew cask install adoptopenjdk10
brew cask install adoptopenjdk11
brew cask install adoptopenjdk12
Jenv it!
brew install jenv
jenv add /Library/Java/JavaVirtualMachines/adoptopenjdk-9.jdk/Contents/Home
jenv add /Library/Java/JavaVirtualMachines/adoptopenjdk-10.jdk/Contents/Home
jenv add /Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home
jenv add /Library/Java/JavaVirtualMachines/adoptopenjdk-12.jdk/Contents/Home
jenv versions
jenv global 12.0
jenv enable-plugin maven
Dock it!
docker run -it openjdk:12-jdk
docker run -it openjdk:13-jdk
docker run -it openjdk:14-jdk
docker run -it amd64/openjdk:15-jdk-oracle /bin/jshell --enable-
preview
docker run -it openjdk:14-jdk /bin/bash
docker run -it -v $(pwd):/tmp openjdk:14-jdk /bin/bash
Java 9 new features
• Modular everything, yeah, we’ve covered that shock already – so you
made your transition to Jigsaw
• JShell
• Private methods in interfaces
• Optional.ifPresentOrElse(), Optional.or(),
Optional.stream()
• Immutable Collection Factories
• Set.of("John", "George", "Betty"); Map.of("John", 1,
"Betty", 2);
• New default GC: G1
Java 10 new features
• var keyword (local-variable type inference)
• Optional.orElseThrow()
• Unmodifiable collections
• List.copyOf(), Set.copyOf(), Map.copyOf()
• Collectors.toUnmodifiableList(),
Collectors.toUnmodifiableSet(),
Collectors.toUnmodifiableMap()
• Better G1: Parallel full GC
• Docker container aware (On Linux platforms)
Java 11 new features
• Local-Variable Syntax for Lambda Parameters
• IntFunction<Integer> doubleIt2 = (var x) -> x * 2;
• IntFunction<Integer> doubleIt2 = (@Valid final var x) -> x * 2;
• Launch Single-File Source-Code Programs
• java SimpleProgram.java
• JDK API
• String::repeat, String::lines
• Optional::isEmpty
• Files::writeString
• Path::of
• ZGC garbage collector
"an"
.repeat(5000)
.lines()
.map(String::toUpperCase)
.forEach(System.out::println)
Java 12 new features
• Preview: Switch statement may return value (JEP 325)
• JEP 341: Default CDS archives
• JEP 230 Microbenchmark suite
• Improved G1 GC: Abortable mixed collections for G1 (JEP 344),
Promptly return unused committed memory from G1 (JEP
346)
• Experimental; Shenandoah low-pause-time GC
var urlList = List.of(
"dev.solita.fi",
"secure.solita.fi"
);
var results = urlList.stream()
.map(x -> switch(x) {
case "dev.solita.fi" -> "ok";
default -> "nok";
}
)
.collect(Collectors.toList());
Class Data Sharing (CDS, JEP 341)
• Basically: Shared cache of architecture specific compilations, an
archive that can be shared across JVMs
• Caches preprocessed class metadata on disk, not same as AOT
• Skips class lookup, load, verification
• Eliminate out-of-the-box startup time
• Observe JDK lib/server folder, default, part of linked Java image
• Can be (re)created with –Xshare:dump
Short history of CDS
• Available already in SUN JVM 1.5,
• …but limited to client JVM, system classes and serial GC algorithm only
• Typically generated upon JRE installation
• Not same as code cache, metaspace, or permgen, as these are owned by each JVM
• OpenJDK/JDK 9, Supports server VM, G1, Serial, Parallel GCs
• Support for own application classes, but only in commercial version
• OpenJDK 10, JEP 310: Applicatiom class data sharing
• Java 12: JEP 341: Eliminate need to run –Xshare:dump to activate (means: regenerate
the archive)
• Currently: Limited, 64-bit only. To control further, -Xshare:auto, -Xshare:off, -Xshare:on
• Java 13: JEP 350
• Also: JEP 250, store interned strings in CDS
Also see: https://simonis.github.io/JEEConf2018/CDS/cds.xhtml
Java Application
OS
Code Cache
CDS (Shared)
Metaspace
Java Heap
JRE (Shared)
Libjvm.so (Shared)
./jdk-12/bin/java -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC -cp ~ Hello
./jdk-12/bin/java -XX:+UnlockExperimentalVMOptions -XX:+UseZGC -cp ~ Hello
Java 13 new features
• JEP 350: Dynamic CDS Archives
• JEP 351: ZGC: Uncommit Unused Memory
• JEP 353: Reimplement the Legacy Socket API
• JEP 354: Switch Expressions (Preview)
• Continues work from Java 12 with yield keyword for blocks that return a
value
• More clarification: switch expression vs switch statement
• JEP 355: Text Blocks (Preview)
• Multiline text blocks, delimited by triple quotes
Verify latest Java features
var x = 1;
var y = switch(x) {
case 1: yield "ok";
case 2: yield "nok";
default: yield "wtf";
};
System.out.println(y);
Java 14 incoming features
• JEP 305: Pattern Matching for instanceof (Preview)
• JEP 343: Packaging Tool (Incubator)
• JEP 345: NUMA-Aware Memory Allocation for G1
(Physical memory sockets)
• JEP 349: JFR Event Streaming (Stream profiling and
diagnostic data from API)
• JEP 352: Non-Volatile Mapped Byte Buffers (Non-
Volatile Mapped Byte Buffers (persist data between
process runs)
• JEP 358: Helpful NullPointerExceptions (Helpful
NullPointerExceptions (Yay!)
• JEP 359: Records (Preview)
• JEP 361: Switch Expressions (Standard, go out of
preview)
• JEP 362: Deprecate the Solaris and SPARC Ports
• JEP 363: Remove the Concurrent Mark Sweep
(CMS) Garbage Collector (Byebye)
• JEP 364 and JEP 365 : ZGC on macOS and ZGC
on Windows
• JEP 366: Deprecate the ParallelScavenge +
SerialOld GC Combination
• JEP 367: Remove the Pack200 Tools and API
• JEP 368: Text Blocks (Second Preview)
• JEP 370: Foreign-Memory Access API (Incubator)
https://openjdk.java.net/projects/jdk/14/
Java 14 instanceof pattern matching
var obj = "oooooo";
if (obj instanceof String str && str.length() > 5) {
System.out.println(str.toUpperCase());
}
Java 14 Records (preview)
record Point(int x, int y) { }
var r1 = new Point(10,20);
var r2 = new Point(10,20);
System.out.println(r1);
System.out.println(r1.equals(r2));
javac --enable-preview -source 14 RecordDemo.java
Java 15 incoming features
• https://openjdk.java.net/projects/jdk/15/
• https://bugs.openjdk.java.net/secure/Dashboard.jspa?selectPageId=19114
• JEP 198: Light-Weight JSON API (Candidate)
• JEP 218: Generics over Primitive Types (Candidate)
• JEP 301: Enhanced Enums (Candidate)
• JEP 302: Lambda Leftovers (Candidate)
• JEP 339: Edwards-Curve Digital Signature Algorithm (EdDSA) (Candidate)
• JEP 356: Enhanced Pseudo-Random Number Generators (Candidate)
• JEP 360: Sealed Types (Preview) (Candidate)
• JEP 371: Hidden Classes (Candidate)
Further readz
• https://metebalci.com/blog/what-is-new-in-java-11/
• https://metebalci.com/blog/what-is-new-in-java-12/
• https://metebalci.com/blog/what-is-new-in-java-13/
• https://openjdk.java.net/projects/jdk/14/
• https://wiki.openjdk.java.net/display/zgc/Main
• https://www.youtube.com/watch?v=E1M3hNlhQCg
• https://blog.plan99.net/modern-garbage-collection-part-2-1c88847abcfd
You are breathtaking!
ARTO SANTALA
Software Architect
arto.santala@solita.fi
More techical content coming up at: dev.solita.fi
Java On Speed

More Related Content

What's hot

jcmd #javacasual
jcmd #javacasualjcmd #javacasual
jcmd #javacasualYuji Kubota
 
I know why your Java is slow
I know why your Java is slowI know why your Java is slow
I know why your Java is slowaragozin
 
JDK9 Features (Summary, 31/Jul/2015) #JJUG
JDK9 Features (Summary, 31/Jul/2015) #JJUGJDK9 Features (Summary, 31/Jul/2015) #JJUG
JDK9 Features (Summary, 31/Jul/2015) #JJUGYuji Kubota
 
자바 성능 강의
자바 성능 강의자바 성능 강의
자바 성능 강의Terry Cho
 
Virtualizing Java in Java (jug.ru)
Virtualizing Java in Java (jug.ru)Virtualizing Java in Java (jug.ru)
Virtualizing Java in Java (jug.ru)aragozin
 
Jdk Tools For Performance Diagnostics
Jdk Tools For Performance DiagnosticsJdk Tools For Performance Diagnostics
Jdk Tools For Performance DiagnosticsDror Bereznitsky
 
Java black box profiling JUG.EKB 2016
Java black box profiling JUG.EKB 2016Java black box profiling JUG.EKB 2016
Java black box profiling JUG.EKB 2016aragozin
 
Java profiling Do It Yourself (jug.msk.ru 2016)
Java profiling Do It Yourself (jug.msk.ru 2016)Java profiling Do It Yourself (jug.msk.ru 2016)
Java profiling Do It Yourself (jug.msk.ru 2016)aragozin
 
Boost Development With Java EE7 On EAP7 (Demitris Andreadis)
Boost Development With Java EE7 On EAP7 (Demitris Andreadis)Boost Development With Java EE7 On EAP7 (Demitris Andreadis)
Boost Development With Java EE7 On EAP7 (Demitris Andreadis)Red Hat Developers
 
Diagnosing Your Application on the JVM
Diagnosing Your Application on the JVMDiagnosing Your Application on the JVM
Diagnosing Your Application on the JVMStaffan Larsen
 
So You Want To Write Your Own Benchmark
So You Want To Write Your Own BenchmarkSo You Want To Write Your Own Benchmark
So You Want To Write Your Own BenchmarkDror Bereznitsky
 
Java Tools and Techniques for Solving Tricky Problem
Java Tools and Techniques for Solving Tricky ProblemJava Tools and Techniques for Solving Tricky Problem
Java Tools and Techniques for Solving Tricky ProblemWill Iverson
 
Oracle Latch and Mutex Contention Troubleshooting
Oracle Latch and Mutex Contention TroubleshootingOracle Latch and Mutex Contention Troubleshooting
Oracle Latch and Mutex Contention TroubleshootingTanel Poder
 
The JVM is your friend
The JVM is your friendThe JVM is your friend
The JVM is your friendKai Koenig
 
Java 9-10 What's New
Java 9-10 What's NewJava 9-10 What's New
Java 9-10 What's NewNicola Pedot
 
An Introduction To Java Profiling
An Introduction To Java ProfilingAn Introduction To Java Profiling
An Introduction To Java Profilingschlebu
 
Intrinsic Methods in HotSpot VM
Intrinsic Methods in HotSpot VMIntrinsic Methods in HotSpot VM
Intrinsic Methods in HotSpot VMKris Mok
 
How to cook lettuce @Java casual
How to cook lettuce @Java casualHow to cook lettuce @Java casual
How to cook lettuce @Java casualGo Hagiwara
 
Java on Linux for devs and ops
Java on Linux for devs and opsJava on Linux for devs and ops
Java on Linux for devs and opsaragozin
 

What's hot (20)

jcmd #javacasual
jcmd #javacasualjcmd #javacasual
jcmd #javacasual
 
I know why your Java is slow
I know why your Java is slowI know why your Java is slow
I know why your Java is slow
 
JDK9 Features (Summary, 31/Jul/2015) #JJUG
JDK9 Features (Summary, 31/Jul/2015) #JJUGJDK9 Features (Summary, 31/Jul/2015) #JJUG
JDK9 Features (Summary, 31/Jul/2015) #JJUG
 
자바 성능 강의
자바 성능 강의자바 성능 강의
자바 성능 강의
 
Virtualizing Java in Java (jug.ru)
Virtualizing Java in Java (jug.ru)Virtualizing Java in Java (jug.ru)
Virtualizing Java in Java (jug.ru)
 
Jdk Tools For Performance Diagnostics
Jdk Tools For Performance DiagnosticsJdk Tools For Performance Diagnostics
Jdk Tools For Performance Diagnostics
 
Java black box profiling JUG.EKB 2016
Java black box profiling JUG.EKB 2016Java black box profiling JUG.EKB 2016
Java black box profiling JUG.EKB 2016
 
Java profiling Do It Yourself (jug.msk.ru 2016)
Java profiling Do It Yourself (jug.msk.ru 2016)Java profiling Do It Yourself (jug.msk.ru 2016)
Java profiling Do It Yourself (jug.msk.ru 2016)
 
Boost Development With Java EE7 On EAP7 (Demitris Andreadis)
Boost Development With Java EE7 On EAP7 (Demitris Andreadis)Boost Development With Java EE7 On EAP7 (Demitris Andreadis)
Boost Development With Java EE7 On EAP7 (Demitris Andreadis)
 
Diagnosing Your Application on the JVM
Diagnosing Your Application on the JVMDiagnosing Your Application on the JVM
Diagnosing Your Application on the JVM
 
So You Want To Write Your Own Benchmark
So You Want To Write Your Own BenchmarkSo You Want To Write Your Own Benchmark
So You Want To Write Your Own Benchmark
 
Java Tools and Techniques for Solving Tricky Problem
Java Tools and Techniques for Solving Tricky ProblemJava Tools and Techniques for Solving Tricky Problem
Java Tools and Techniques for Solving Tricky Problem
 
Oracle Latch and Mutex Contention Troubleshooting
Oracle Latch and Mutex Contention TroubleshootingOracle Latch and Mutex Contention Troubleshooting
Oracle Latch and Mutex Contention Troubleshooting
 
The JVM is your friend
The JVM is your friendThe JVM is your friend
The JVM is your friend
 
Java 9-10 What's New
Java 9-10 What's NewJava 9-10 What's New
Java 9-10 What's New
 
An Introduction To Java Profiling
An Introduction To Java ProfilingAn Introduction To Java Profiling
An Introduction To Java Profiling
 
Intrinsic Methods in HotSpot VM
Intrinsic Methods in HotSpot VMIntrinsic Methods in HotSpot VM
Intrinsic Methods in HotSpot VM
 
How to cook lettuce @Java casual
How to cook lettuce @Java casualHow to cook lettuce @Java casual
How to cook lettuce @Java casual
 
Thread dumps
Thread dumpsThread dumps
Thread dumps
 
Java on Linux for devs and ops
Java on Linux for devs and opsJava on Linux for devs and ops
Java on Linux for devs and ops
 

Similar to Java On Speed

Java 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from OredevJava 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from OredevMattias Karlsson
 
Introduction to java
Introduction to java Introduction to java
Introduction to java Sandeep Rawat
 
Highlights from Java 10, 11 and 12 and Future of Java at Javaland 2019 By Vad...
Highlights from Java 10, 11 and 12 and Future of Java at Javaland 2019 By Vad...Highlights from Java 10, 11 and 12 and Future of Java at Javaland 2019 By Vad...
Highlights from Java 10, 11 and 12 and Future of Java at Javaland 2019 By Vad...Vadym Kazulkin
 
Object Oriented Programming-JAVA
Object Oriented Programming-JAVAObject Oriented Programming-JAVA
Object Oriented Programming-JAVAHome
 
Практики применения JRuby
Практики применения JRubyПрактики применения JRuby
Практики применения JRuby.toster
 
Haj 4344-java se 9 and the application server-1
Haj 4344-java se 9 and the application server-1Haj 4344-java se 9 and the application server-1
Haj 4344-java se 9 and the application server-1Kevin Sutter
 
Java and OpenJDK: disecting the ecosystem
Java and OpenJDK: disecting the ecosystemJava and OpenJDK: disecting the ecosystem
Java and OpenJDK: disecting the ecosystemRafael Winterhalter
 
Java Future S Ritter
Java Future S RitterJava Future S Ritter
Java Future S Rittercatherinewall
 
Industrial Strength Groovy - Tools for the Professional Groovy Developer: Pau...
Industrial Strength Groovy - Tools for the Professional Groovy Developer: Pau...Industrial Strength Groovy - Tools for the Professional Groovy Developer: Pau...
Industrial Strength Groovy - Tools for the Professional Groovy Developer: Pau...Paul King
 
Migrating to Java 11
Migrating to Java 11Migrating to Java 11
Migrating to Java 11Arto Santala
 
Java/Spring과 Node.js의 공존 시즌2
Java/Spring과 Node.js의 공존 시즌2Java/Spring과 Node.js의 공존 시즌2
Java/Spring과 Node.js의 공존 시즌2동수 장
 
JCConf 2018 - Retrospect and Prospect of Java
JCConf 2018 - Retrospect and Prospect of JavaJCConf 2018 - Retrospect and Prospect of Java
JCConf 2018 - Retrospect and Prospect of JavaJoseph Kuo
 
Head toward Java 14 and Java 15
Head toward Java 14 and Java 15Head toward Java 14 and Java 15
Head toward Java 14 and Java 15Yuji Kubota
 
A tour of Java and the JVM
A tour of Java and the JVMA tour of Java and the JVM
A tour of Java and the JVMAlex Birch
 
DevNexus 2020: Discover Modern Java
DevNexus 2020: Discover Modern JavaDevNexus 2020: Discover Modern Java
DevNexus 2020: Discover Modern JavaHenri Tremblay
 

Similar to Java On Speed (20)

Java 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from OredevJava 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from Oredev
 
Panama.pdf
Panama.pdfPanama.pdf
Panama.pdf
 
Java 9 new features
Java 9 new featuresJava 9 new features
Java 9 new features
 
HotSpotコトハジメ
HotSpotコトハジメHotSpotコトハジメ
HotSpotコトハジメ
 
Introduction to java
Introduction to java Introduction to java
Introduction to java
 
Highlights from Java 10, 11 and 12 and Future of Java at Javaland 2019 By Vad...
Highlights from Java 10, 11 and 12 and Future of Java at Javaland 2019 By Vad...Highlights from Java 10, 11 and 12 and Future of Java at Javaland 2019 By Vad...
Highlights from Java 10, 11 and 12 and Future of Java at Javaland 2019 By Vad...
 
Object Oriented Programming-JAVA
Object Oriented Programming-JAVAObject Oriented Programming-JAVA
Object Oriented Programming-JAVA
 
Практики применения JRuby
Практики применения JRubyПрактики применения JRuby
Практики применения JRuby
 
Java Programming - 01 intro to java
Java Programming - 01 intro to javaJava Programming - 01 intro to java
Java Programming - 01 intro to java
 
Haj 4344-java se 9 and the application server-1
Haj 4344-java se 9 and the application server-1Haj 4344-java se 9 and the application server-1
Haj 4344-java se 9 and the application server-1
 
Java and OpenJDK: disecting the ecosystem
Java and OpenJDK: disecting the ecosystemJava and OpenJDK: disecting the ecosystem
Java and OpenJDK: disecting the ecosystem
 
Java Future S Ritter
Java Future S RitterJava Future S Ritter
Java Future S Ritter
 
Industrial Strength Groovy - Tools for the Professional Groovy Developer: Pau...
Industrial Strength Groovy - Tools for the Professional Groovy Developer: Pau...Industrial Strength Groovy - Tools for the Professional Groovy Developer: Pau...
Industrial Strength Groovy - Tools for the Professional Groovy Developer: Pau...
 
Migrating to Java 11
Migrating to Java 11Migrating to Java 11
Migrating to Java 11
 
Java/Spring과 Node.js의 공존 시즌2
Java/Spring과 Node.js의 공존 시즌2Java/Spring과 Node.js의 공존 시즌2
Java/Spring과 Node.js의 공존 시즌2
 
Karaf ee-apachecon eu-2012
Karaf ee-apachecon eu-2012Karaf ee-apachecon eu-2012
Karaf ee-apachecon eu-2012
 
JCConf 2018 - Retrospect and Prospect of Java
JCConf 2018 - Retrospect and Prospect of JavaJCConf 2018 - Retrospect and Prospect of Java
JCConf 2018 - Retrospect and Prospect of Java
 
Head toward Java 14 and Java 15
Head toward Java 14 and Java 15Head toward Java 14 and Java 15
Head toward Java 14 and Java 15
 
A tour of Java and the JVM
A tour of Java and the JVMA tour of Java and the JVM
A tour of Java and the JVM
 
DevNexus 2020: Discover Modern Java
DevNexus 2020: Discover Modern JavaDevNexus 2020: Discover Modern Java
DevNexus 2020: Discover Modern Java
 

More from Arto Santala

Your Brain on Java
Your Brain on JavaYour Brain on Java
Your Brain on JavaArto Santala
 
API Design: 7 kuolemansyntiä
API Design: 7 kuolemansyntiäAPI Design: 7 kuolemansyntiä
API Design: 7 kuolemansyntiäArto Santala
 
Leaner microservices with Java 10
Leaner microservices with Java 10Leaner microservices with Java 10
Leaner microservices with Java 10Arto Santala
 
Automate Everything! (No stress development/Tallinn)
Automate Everything! (No stress development/Tallinn)Automate Everything! (No stress development/Tallinn)
Automate Everything! (No stress development/Tallinn)Arto Santala
 
Solita /dev/cloud kickstart
Solita /dev/cloud kickstartSolita /dev/cloud kickstart
Solita /dev/cloud kickstartArto Santala
 
Kontit pomppimaan3
Kontit pomppimaan3Kontit pomppimaan3
Kontit pomppimaan3Arto Santala
 
Java9 moduulit jigsaw
Java9 moduulit jigsawJava9 moduulit jigsaw
Java9 moduulit jigsawArto Santala
 
Syvemmälle javaan
Syvemmälle javaanSyvemmälle javaan
Syvemmälle javaanArto Santala
 
JavaOne 2016 short highlights
JavaOne 2016 short highlightsJavaOne 2016 short highlights
JavaOne 2016 short highlightsArto Santala
 

More from Arto Santala (9)

Your Brain on Java
Your Brain on JavaYour Brain on Java
Your Brain on Java
 
API Design: 7 kuolemansyntiä
API Design: 7 kuolemansyntiäAPI Design: 7 kuolemansyntiä
API Design: 7 kuolemansyntiä
 
Leaner microservices with Java 10
Leaner microservices with Java 10Leaner microservices with Java 10
Leaner microservices with Java 10
 
Automate Everything! (No stress development/Tallinn)
Automate Everything! (No stress development/Tallinn)Automate Everything! (No stress development/Tallinn)
Automate Everything! (No stress development/Tallinn)
 
Solita /dev/cloud kickstart
Solita /dev/cloud kickstartSolita /dev/cloud kickstart
Solita /dev/cloud kickstart
 
Kontit pomppimaan3
Kontit pomppimaan3Kontit pomppimaan3
Kontit pomppimaan3
 
Java9 moduulit jigsaw
Java9 moduulit jigsawJava9 moduulit jigsaw
Java9 moduulit jigsaw
 
Syvemmälle javaan
Syvemmälle javaanSyvemmälle javaan
Syvemmälle javaan
 
JavaOne 2016 short highlights
JavaOne 2016 short highlightsJavaOne 2016 short highlights
JavaOne 2016 short highlights
 

Recently uploaded

MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfStefano Stabellini
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 

Recently uploaded (20)

MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdf
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 

Java On Speed

  • 1. Java on speed What’s new in Java 9, 10, 11, 12, 13 and 14? arto.santala@solita.fi
  • 2. Useful and coherent examples on how to use latest versions of Java
  • 3. Just kidding. There are none, so… Lets just muck it up
  • 4. 1995 2020 19 years to Java 8 6 years from 8 to 15 New version ever 1.5 years
  • 5. Brew some Java brew tap AdoptOpenJDK/openjdk brew search jdk brew cask install adoptopenjdk9 brew cask install adoptopenjdk10 brew cask install adoptopenjdk11 brew cask install adoptopenjdk12
  • 6. Jenv it! brew install jenv jenv add /Library/Java/JavaVirtualMachines/adoptopenjdk-9.jdk/Contents/Home jenv add /Library/Java/JavaVirtualMachines/adoptopenjdk-10.jdk/Contents/Home jenv add /Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home jenv add /Library/Java/JavaVirtualMachines/adoptopenjdk-12.jdk/Contents/Home jenv versions jenv global 12.0 jenv enable-plugin maven
  • 7. Dock it! docker run -it openjdk:12-jdk docker run -it openjdk:13-jdk docker run -it openjdk:14-jdk docker run -it amd64/openjdk:15-jdk-oracle /bin/jshell --enable- preview docker run -it openjdk:14-jdk /bin/bash docker run -it -v $(pwd):/tmp openjdk:14-jdk /bin/bash
  • 8. Java 9 new features • Modular everything, yeah, we’ve covered that shock already – so you made your transition to Jigsaw • JShell • Private methods in interfaces • Optional.ifPresentOrElse(), Optional.or(), Optional.stream() • Immutable Collection Factories • Set.of("John", "George", "Betty"); Map.of("John", 1, "Betty", 2); • New default GC: G1
  • 9. Java 10 new features • var keyword (local-variable type inference) • Optional.orElseThrow() • Unmodifiable collections • List.copyOf(), Set.copyOf(), Map.copyOf() • Collectors.toUnmodifiableList(), Collectors.toUnmodifiableSet(), Collectors.toUnmodifiableMap() • Better G1: Parallel full GC • Docker container aware (On Linux platforms)
  • 10.
  • 11. Java 11 new features • Local-Variable Syntax for Lambda Parameters • IntFunction<Integer> doubleIt2 = (var x) -> x * 2; • IntFunction<Integer> doubleIt2 = (@Valid final var x) -> x * 2; • Launch Single-File Source-Code Programs • java SimpleProgram.java • JDK API • String::repeat, String::lines • Optional::isEmpty • Files::writeString • Path::of • ZGC garbage collector
  • 13. Java 12 new features • Preview: Switch statement may return value (JEP 325) • JEP 341: Default CDS archives • JEP 230 Microbenchmark suite • Improved G1 GC: Abortable mixed collections for G1 (JEP 344), Promptly return unused committed memory from G1 (JEP 346) • Experimental; Shenandoah low-pause-time GC
  • 14. var urlList = List.of( "dev.solita.fi", "secure.solita.fi" ); var results = urlList.stream() .map(x -> switch(x) { case "dev.solita.fi" -> "ok"; default -> "nok"; } ) .collect(Collectors.toList());
  • 15. Class Data Sharing (CDS, JEP 341) • Basically: Shared cache of architecture specific compilations, an archive that can be shared across JVMs • Caches preprocessed class metadata on disk, not same as AOT • Skips class lookup, load, verification • Eliminate out-of-the-box startup time • Observe JDK lib/server folder, default, part of linked Java image • Can be (re)created with –Xshare:dump
  • 16. Short history of CDS • Available already in SUN JVM 1.5, • …but limited to client JVM, system classes and serial GC algorithm only • Typically generated upon JRE installation • Not same as code cache, metaspace, or permgen, as these are owned by each JVM • OpenJDK/JDK 9, Supports server VM, G1, Serial, Parallel GCs • Support for own application classes, but only in commercial version • OpenJDK 10, JEP 310: Applicatiom class data sharing • Java 12: JEP 341: Eliminate need to run –Xshare:dump to activate (means: regenerate the archive) • Currently: Limited, 64-bit only. To control further, -Xshare:auto, -Xshare:off, -Xshare:on • Java 13: JEP 350 • Also: JEP 250, store interned strings in CDS Also see: https://simonis.github.io/JEEConf2018/CDS/cds.xhtml
  • 17. Java Application OS Code Cache CDS (Shared) Metaspace Java Heap JRE (Shared) Libjvm.so (Shared)
  • 18. ./jdk-12/bin/java -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC -cp ~ Hello ./jdk-12/bin/java -XX:+UnlockExperimentalVMOptions -XX:+UseZGC -cp ~ Hello
  • 19. Java 13 new features • JEP 350: Dynamic CDS Archives • JEP 351: ZGC: Uncommit Unused Memory • JEP 353: Reimplement the Legacy Socket API • JEP 354: Switch Expressions (Preview) • Continues work from Java 12 with yield keyword for blocks that return a value • More clarification: switch expression vs switch statement • JEP 355: Text Blocks (Preview) • Multiline text blocks, delimited by triple quotes
  • 20. Verify latest Java features var x = 1; var y = switch(x) { case 1: yield "ok"; case 2: yield "nok"; default: yield "wtf"; }; System.out.println(y);
  • 21. Java 14 incoming features • JEP 305: Pattern Matching for instanceof (Preview) • JEP 343: Packaging Tool (Incubator) • JEP 345: NUMA-Aware Memory Allocation for G1 (Physical memory sockets) • JEP 349: JFR Event Streaming (Stream profiling and diagnostic data from API) • JEP 352: Non-Volatile Mapped Byte Buffers (Non- Volatile Mapped Byte Buffers (persist data between process runs) • JEP 358: Helpful NullPointerExceptions (Helpful NullPointerExceptions (Yay!) • JEP 359: Records (Preview) • JEP 361: Switch Expressions (Standard, go out of preview) • JEP 362: Deprecate the Solaris and SPARC Ports • JEP 363: Remove the Concurrent Mark Sweep (CMS) Garbage Collector (Byebye) • JEP 364 and JEP 365 : ZGC on macOS and ZGC on Windows • JEP 366: Deprecate the ParallelScavenge + SerialOld GC Combination • JEP 367: Remove the Pack200 Tools and API • JEP 368: Text Blocks (Second Preview) • JEP 370: Foreign-Memory Access API (Incubator) https://openjdk.java.net/projects/jdk/14/
  • 22. Java 14 instanceof pattern matching var obj = "oooooo"; if (obj instanceof String str && str.length() > 5) { System.out.println(str.toUpperCase()); }
  • 23. Java 14 Records (preview) record Point(int x, int y) { } var r1 = new Point(10,20); var r2 = new Point(10,20); System.out.println(r1); System.out.println(r1.equals(r2)); javac --enable-preview -source 14 RecordDemo.java
  • 24. Java 15 incoming features • https://openjdk.java.net/projects/jdk/15/ • https://bugs.openjdk.java.net/secure/Dashboard.jspa?selectPageId=19114 • JEP 198: Light-Weight JSON API (Candidate) • JEP 218: Generics over Primitive Types (Candidate) • JEP 301: Enhanced Enums (Candidate) • JEP 302: Lambda Leftovers (Candidate) • JEP 339: Edwards-Curve Digital Signature Algorithm (EdDSA) (Candidate) • JEP 356: Enhanced Pseudo-Random Number Generators (Candidate) • JEP 360: Sealed Types (Preview) (Candidate) • JEP 371: Hidden Classes (Candidate)
  • 25. Further readz • https://metebalci.com/blog/what-is-new-in-java-11/ • https://metebalci.com/blog/what-is-new-in-java-12/ • https://metebalci.com/blog/what-is-new-in-java-13/ • https://openjdk.java.net/projects/jdk/14/ • https://wiki.openjdk.java.net/display/zgc/Main • https://www.youtube.com/watch?v=E1M3hNlhQCg • https://blog.plan99.net/modern-garbage-collection-part-2-1c88847abcfd
  • 26. You are breathtaking! ARTO SANTALA Software Architect arto.santala@solita.fi More techical content coming up at: dev.solita.fi

Editor's Notes

  1. https://open.spotify.com/track/5RcKimxPKcDcrrSdEsgCWf?si=e96TVVnvSpO3WxwlihwVVg https://open.spotify.com/track/2cnUciCHWE9pXWX4kVWRnk?si=1-RFAKCdT6yaxEvTiUAuRQ https://open.spotify.com/track/3cTHANO2kjJ0hutSon5Wu0?si=Bfw_hqTuSZajrzXyLu7TTA https://open.spotify.com/track/7ggIfOV6INPrvh8qi7UnIC?si=UPg4hMHfQAeHo5mOfCtvpw
  2. https://gist.github.com/fcamblor/8a183ad77ff5c5a41d0c400e66231731
  3. https://gist.github.com/fcamblor/8a183ad77ff5c5a41d0c400e66231731
  4. https://codete.com/blog/java-8-java-11-quick-guide/
  5. Any attempt to modify such a collection would result in java.lang.UnsupportedOperationExceptionruntime exception.
  6. You may need to provide --enable-preview and -source 11 flags to javac and --enable-preview flag to java.
  7. https://stackify.com/java-12-new-features-and-enhancements-developers-should-know/ https://metebalci.com/blog/what-is-new-in-java-12/ You may need to provide --enable-preview and -source 12 flags to javac and --enable-preview flag to java. Class Data-Sharing (CDS) is a feature to reduce startup time and benefit from memory sharing. However, if you do not install the JRE with the installer, the CDS archive is not generated by default and java -Xshare:dump has to be run manually. This can be observed in JDK 11. If you install the JDK 11 GA Release from http://jdk.java.net/11/ , lib/server folder does not contain the CDS archive, classes.jsa file. If you run java -Xshare:dump, it will be generated. With this JEP, CDS archive will be generated by default. Ls /Library/Java/JavaVirtualMachines/adoptopenjdk-12.jdk/Contents/Home Shenandoah Once more, do GC while app keeps on running Scale better by amount of memory Experimental
  8. var urlList = List.of("dev.solita.fi","secure.solita.fi"); var results = urlList.stream() .map(x -> switch(x) { case "dev.solita.fi" -> "ok"; default -> "nok"; }).collect(Collectors.toList());
  9. java -Xshare:off -jar libs/example-0.1-all.jar [raaka@wickedwitch server]$ java -version openjdk version "12.0.1" 2019-04-16 OpenJDK Runtime Environment AdoptOpenJDK (build 12.0.1+12) OpenJDK 64-Bit Server VM AdoptOpenJDK (build 12.0.1+12, mixed mode, sharing)
  10. https://metebalci.com/blog/what-is-new-in-java-13/ You may need to provide --enable-preview and -source 13 flags to javac and --enable-preview flag to java.
  11. Limitation of using records: Records cannot extend any other class, and cannot declare instance fields other than the private final fields which correspond to components of the state description Records are implicitly final, and cannot be abstract Such limitations underline that a record's API is entirely defined by its state definition and can not be modified by another class or record later. The components of a record are implicitly final. public record FXOrder(int units, CurrencyPair pair, Side side, double price, LocalDateTime sentAt, int ttl ) {}
  12. https://twitter.com/SolitaOy https://www.facebook.com/Solita https://www.linkedin.com/company/solita-oy/ https://www.youtube.com/user/SolitaOy