SlideShare a Scribd company logo
1 of 44
sbordet@webtide.com
Java 9/10/11
What’s new and why you should upgrade
@simonebordet
sbordet@webtide.com
Simone Bordet
● @simonebordet
● sbordet@webtide.com
● Java Champion
● Works @ Webtide
○ The company behind Jetty and CometD
sbordet@webtide.com
Java 11
● Java 11 is here!
● “Long Term Support” (LTS) Release
○ Java 8 was the previous LTS Release
○ Java 9 and Java 10 already unmaintained
sbordet@webtide.com
Java 11
OpenJDK 11 Repository
https://hg.openjdk.java.net
Oracle JDK Binary
https://java.oracle.com
OpenJDK Binary
http://jdk.java.net/11
RedHat JDK
Binary
Azul JDK Binary (Zulu)
AdoptOpenJDK Binary
https://adoptopenjdk.net
sbordet@webtide.com
Java 11
● What does LTS really mean?
● During the 6 months of “life” of a Java 11:
○ OpenJDK Binary -> GPL
○ AdoptOpenJDK -> GPL
○ Azul Zulu -> GPL
○ Oracle JDK Binary -> Oracle License
■ MUST PAY Oracle for production use
sbordet@webtide.com
Java 11
● After the 6 months of “life” of a Java 11:
○ Upgrade to Java 12
○ Stay on Java 11
sbordet@webtide.com
● After 6 months, you stay on Java 11
○ Never update -> exposed to vulnerabilities
○ Update Java 11 -> 11.0.x
● Community (RedHat) backports fixes
● Vendors create binary builds
○ AdoptOpenJDK -> GPL
○ Other vendors (Oracle, Azul, RedHat, …) -> PAY
Java 11
sbordet@webtide.com
Java 9
New Features
sbordet@webtide.com
Java 9
● Java 9 introduced the Java Module System
● Along with it, a number of breaking changes
○ Upgrading from 8 to 9/10/11 is NOT simple
○ Many runtime behavior changes
○ Needs very thorough testing
sbordet@webtide.com
Java 9
● Removed tools.jar
○ Attach API, Compiler API, JavaDoc API, etc.
● Removed JavaDB
● Removed endorsed and extension directories
○ $JAVA_HOME/lib/endorsed
○ $JAVA_HOME/jre/lib/ext
sbordet@webtide.com
Java 9
● Class loading implementation changed
○ Different behavior to support modules
ClassLoader sysCL = ClassLoader.getSystemClassLoader();
// Throws ClassCastException now!
URLClassLoader urlCL = (URLClassLoader)sysCL;
sbordet@webtide.com
Java 9
● Loading resources
URL resource = sysCL.getResource("java/lang/String.class");
// Not a file:/ nor a jar:/ URL!
resource = jrt:/java.base/java/lang/String.class
URL resource = sysCL.getResource("/com/foo/bar.properties");
// It’s there, but it won’t find it!
resource = null;
sbordet@webtide.com
Java 9
● New version string scheme
○ 1.8.0_181 -> 9.0.1
○ Broke many Maven Plugins, Jetty, etc.
● JDK 9’s java.lang.Runtime.Version class
○ Cannot parse JDK 8 version string
○ Must implement custom parsing to support both
sbordet@webtide.com
Java 9
● Internal APIs encapsulated
○ Cannot access sun.* or com.sun.* classes
● Finalization
○ sun.misc.Cleaner -> java.lang.ref.Cleaner
○ Object.finalize() -> deprecated
● Unsafe
○ Some sun.misc.Unsafe usage replaced by VarHandle
sbordet@webtide.com
Java 9
● Multi Release jars
com/
acme/
A.class
B.class
META-INF/
versions/
9/
com/
acme/
A.class <- Replaces normal A.class
C.class
sbordet@webtide.com
Java 9
● Variable Handles
○ Expose some Unsafe functionality
class ConcurrentLinkedQueue_BAD {
// BAD, adds indirection
AtomicReference<Node> head;
}
sbordet@webtide.com
Java 9
class ConcurrentLinkedQueue {
private Node head;
private static final VarHandle HEAD;
static {
HEAD = MethodHandles.lookup()
.findVarHandle(ConcurrentLinkedQueue.class,
"head", Node.class);
}
public void m() {
if (HEAD.compareAndSet(...))
...
}
}
}
sbordet@webtide.com
Java 9
● Process APIs
Process p = new ProcessBuilder()
.command("java")
.directory(new File("/tmp"))
.redirectOutput(Redirect.DISCARD)
.start();
ProcessHandle.of(p.pid())
.orElseThrow(IllegalStateException::new)
.onExit()
.thenAccept(h ->
System.err.printf("%d exited%n", h.pid())
);
sbordet@webtide.com
Java 9
● Concurrent APIs Enhancements
○ java.util.concurrent.Flow
■ Identical APIs and semantic of ReactiveStreams
○ CompletableFuture enhancements
■ Common scheduler for timeout functionalities
CompletableFuture.supplyAsync(() -> longJob())
.completeOnTimeout("N/A", 1, TimeUnit.SECONDS)
CompletableFuture.supplyAsync(() -> longJob())
.orTimeout(1, TimeUnit.SECONDS)
sbordet@webtide.com
Java 9
● jshell - Read-Eval-Print-Loop (REPL)
● Pretty powerful!
○ AutoCompletion, Imports, Javadocs
○ History, search
○ Syncs with external editor
○ Function and forward references
○ ...
sbordet@webtide.com
Java 9
● G1 is the default Garbage Collector
● Much improved from 8 and even better in 11
○ Adaptive start of concurrent mark
○ Made internal data structures more concurrent
○ More phases parallelized
○ Reduced contention
○ Reduced memory consumption
sbordet@webtide.com
Java 9
● Unified GC logging
○ Not compatible with previous GC logs
● Every GC logs differently
● Example
○ -
Xlog:gc*,ergo*=trace,ref*=debug:file=log
s/gc.log:time,level,tags
sbordet@webtide.com
Java 9
● JVM options changes
○ 50 options removed - JVM refuses to start
○ 18 options ignored - 12 options deprecated
● Must review your command line!
○ Especially if you had custom GC tuning options
sbordet@webtide.com
Java 10
New Features
sbordet@webtide.com
Java 10
● Local variable type inference (a.k.a. var)
○ http://openjdk.java.net/projects/amber/LVTIstyle.html
// Infers ArrayList<String>
var list = new ArrayList<String>();
// infers Stream<String>
var stream = list.stream();
sbordet@webtide.com
Java 10
● var is not a keyword, it is a reserved type name
○ It’s a valid identifier, unless used in places where the
compiler expects a type name
int var = 13;
sbordet@webtide.com
Java 10
● Good var usage
var message = "warning, too many features";
var anon = new Object() {
int count = 0;
}
anon.count++; // Compiles!
sbordet@webtide.com
Java 10
● Controversial var usage
// What type ?
var result = processor.run();
// IDE cannot help you
var list = new <ctrl+space>
sbordet@webtide.com
Java 10
● Experimental Graal JIT
○ https://www.graalvm.org/
● -XX:+UnlockExperimentalVMOptions -XX:
+UseJVMCICompiler
● Not yet recommended in production
○ Twitter uses it in production, you may too (YMMV)
sbordet@webtide.com
Java 10
● Docker awareness
○ On by default
○ https://blog.docker.com/2018/04/improved-docker-containe
-XX:-UseContainerSupport
-XX:ActiveProcessorCount=n
-XX:MinRAMPercentage=p
-XX:InitialRAMPercentage=p
-XX:MaxRAMPercentage=p
sbordet@webtide.com
Java 11
New Features
sbordet@webtide.com
Java 11
● Two new Garbage Collectors
○ Epsilon GC
○ ZGC
● Epsilon GC
○ No-operation GC
sbordet@webtide.com
● ZGC
○ 5 years of closed source development @ Oracle
○ XX:+UnlockExperimentalVMOptions XX:+UseZGC
○ Single Generation, Region Based
○ Concurrent Marking
○ Concurrent Compaction
○ Very low STW pause times
Java 11
sbordet@webtide.com
Java 11
● Removed methods
○ Thread.stop(Throwable)
○ Thread.destroy()
○ System.runFinalizersOnExit(boolean)
○ Some SecurityManager.check*() methods
sbordet@webtide.com
Java 11
● Removed modules
○ java.activation (JAF)
○ java.corba
○ java.transaction (JTA)
○ java.xml.bind (JAXB)
○ java.xml.ws (JAX-WS)
○ java.xml.ws.annotation (@PostConstruct, ...)
● Replaced by standalone jars
○ https://dzone.com/articles/apis-to-be-removed-from-java-11
sbordet@webtide.com
Java 11
● Java Flight Recorder
○ Open Sourced by Oracle, included in OpenJDK 11
○ java -XX:StartFlightRecording ...
● Java Mission Control
○ Open Sourced by Oracle
○ Downloads at https://jdk.java.net/jmc/
○ JMC 7 scheduled for January 2019
sbordet@webtide.com
Java 11
● TLS 1.3
○ More secure and recent version of TLS
○ Removed vulnerable/weak ciphers
○ Added new ciphers and algorithms
● Using SSLEngine? Verify it works!
sbordet@webtide.com
Java 11
● Launch Single-File Source-Code programs
$ java Hello.java
● Compiled in-memory with Graal
● Teaching
● Java Scripts
sbordet@webtide.com
Java 11
● HTTP client
○ Supports both HTTP/1.1 and HTTP/2
○ Based on the j.u.c.Flow APIs
HttpClient c = HttpClient.newBuilder().build();
HttpRequest r = HttpRequest.newBuilder()
.uri(...).build();
CompletableFuture<String> f = c.sendAsync(r,
BodyHandlers.ofString());
sbordet@webtide.com
Java 11
● Nest Mates
○ Inner (nested) classes introduced in Java 1.1
○ Outer class can access inner class
■ Via compiler tricks - bridge methods
java.lang.UnsupportedOperationException
at NestExample.init(NestExample.java)
at NestExample.access$000(NestExample.java)
at NestExample$Inner.(NestExample.java)
at NestExample.main(NestExample.java)
sbordet@webtide.com
Java 11
● Nest Mates
○ Now specified in the JVM Specification
○ New class file attribute
○ New reflection APIs: Class.getNestMembers(), ...
○ New JVM access controls at runtime
● Do you play with bytecode?
○ Use ASM 7+
sbordet@webtide.com
Conclusions
sbordet@webtide.com
Conclusions
● Upgrade from Java 8 takes time
○ Lots of runtime changes
● Java 8 will be soon unmaintained / unavailable
○ Skip Java 9 and Java 10 - go straight to Java 11
● Lots of good stuff and more coming
○ And coming every 6 months now!
sbordet@webtide.com
Questions?

More Related Content

What's hot

Java Persistence API (JPA) Step By Step
Java Persistence API (JPA) Step By StepJava Persistence API (JPA) Step By Step
Java Persistence API (JPA) Step By Step
Guo Albert
 

What's hot (20)

Java modules
Java modulesJava modules
Java modules
 
Java Interview Questions and Answers | Spring and Hibernate Interview Questio...
Java Interview Questions and Answers | Spring and Hibernate Interview Questio...Java Interview Questions and Answers | Spring and Hibernate Interview Questio...
Java Interview Questions and Answers | Spring and Hibernate Interview Questio...
 
Upgrade to java 16 or 17
Upgrade to java 16 or 17Upgrade to java 16 or 17
Upgrade to java 16 or 17
 
Gradle - the Enterprise Automation Tool
Gradle  - the Enterprise Automation ToolGradle  - the Enterprise Automation Tool
Gradle - the Enterprise Automation Tool
 
JUnit 5
JUnit 5JUnit 5
JUnit 5
 
java 8 new features
java 8 new features java 8 new features
java 8 new features
 
Deep Dive Java 17 Devoxx UK
Deep Dive Java 17 Devoxx UKDeep Dive Java 17 Devoxx UK
Deep Dive Java 17 Devoxx UK
 
Spring boot Introduction
Spring boot IntroductionSpring boot Introduction
Spring boot Introduction
 
Java Persistence API (JPA) Step By Step
Java Persistence API (JPA) Step By StepJava Persistence API (JPA) Step By Step
Java Persistence API (JPA) Step By Step
 
Testing with JUnit 5 and Spring
Testing with JUnit 5 and SpringTesting with JUnit 5 and Spring
Testing with JUnit 5 and Spring
 
Java Spring Framework
Java Spring FrameworkJava Spring Framework
Java Spring Framework
 
Nouveautés Java 9-10-11
Nouveautés Java 9-10-11Nouveautés Java 9-10-11
Nouveautés Java 9-10-11
 
Introduction to Spring Framework and Spring IoC
Introduction to Spring Framework and Spring IoCIntroduction to Spring Framework and Spring IoC
Introduction to Spring Framework and Spring IoC
 
Core java concepts
Core java  conceptsCore java  concepts
Core java concepts
 
Java Concurrency by Example
Java Concurrency by ExampleJava Concurrency by Example
Java Concurrency by Example
 
An Introduction to Gradle for Java Developers
An Introduction to Gradle for Java DevelopersAn Introduction to Gradle for Java Developers
An Introduction to Gradle for Java Developers
 
Discover Quarkus and GraalVM
Discover Quarkus and GraalVMDiscover Quarkus and GraalVM
Discover Quarkus and GraalVM
 
Spring annotation
Spring annotationSpring annotation
Spring annotation
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Spring Framework
Spring Framework  Spring Framework
Spring Framework
 

Similar to Java 9/10/11 - What's new and why you should upgrade

Jigsaw - Javaforum 2015Q4
Jigsaw - Javaforum 2015Q4Jigsaw - Javaforum 2015Q4
Jigsaw - Javaforum 2015Q4
Rikard Thulin
 

Similar to Java 9/10/11 - What's new and why you should upgrade (20)

Java 9-10 What's New
Java 9-10 What's NewJava 9-10 What's New
Java 9-10 What's New
 
Java 10 - Updates
Java 10 - UpdatesJava 10 - Updates
Java 10 - Updates
 
Java 9 - Part1: New Features (Not Jigsaw Modules)
Java 9 - Part1: New Features (Not Jigsaw Modules)Java 9 - Part1: New Features (Not Jigsaw Modules)
Java 9 - Part1: New Features (Not Jigsaw Modules)
 
QConSP 2018 - Java Module System
QConSP 2018 - Java Module SystemQConSP 2018 - Java Module System
QConSP 2018 - Java Module System
 
Prepare for JDK 9
Prepare for JDK 9Prepare for JDK 9
Prepare for JDK 9
 
Java 9 and Project Jigsaw
Java 9 and Project JigsawJava 9 and Project Jigsaw
Java 9 and Project Jigsaw
 
Using FXML on Clojure
Using FXML on ClojureUsing FXML on Clojure
Using FXML on Clojure
 
Dart the Better JavaScript
Dart the Better JavaScriptDart the Better JavaScript
Dart the Better JavaScript
 
Java and OpenJDK: disecting the ecosystem
Java and OpenJDK: disecting the ecosystemJava and OpenJDK: disecting the ecosystem
Java and OpenJDK: disecting the ecosystem
 
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...
 
Java SE 9 modules - an introduction (July 2018)
Java SE 9 modules - an introduction (July 2018)Java SE 9 modules - an introduction (July 2018)
Java SE 9 modules - an introduction (July 2018)
 
DCSF19 Docker Containers & Java: What I Wish I Had Been Told
DCSF19 Docker Containers & Java: What I Wish I Had Been ToldDCSF19 Docker Containers & Java: What I Wish I Had Been Told
DCSF19 Docker Containers & Java: What I Wish I Had Been Told
 
Jigsaw - Javaforum 2015Q4
Jigsaw - Javaforum 2015Q4Jigsaw - Javaforum 2015Q4
Jigsaw - Javaforum 2015Q4
 
GeoServer Developers Workshop
GeoServer Developers WorkshopGeoServer Developers Workshop
GeoServer Developers Workshop
 
Ad111
Ad111Ad111
Ad111
 
AD111 -- Harnessing the Power of Server-Side JavaScript and Other Advanced XP...
AD111 -- Harnessing the Power of Server-Side JavaScript and Other Advanced XP...AD111 -- Harnessing the Power of Server-Side JavaScript and Other Advanced XP...
AD111 -- Harnessing the Power of Server-Side JavaScript and Other Advanced XP...
 
Native Java with GraalVM
Native Java with GraalVMNative Java with GraalVM
Native Java with GraalVM
 
Javascript training sample
Javascript training sampleJavascript training sample
Javascript training sample
 
Whats new in Java 9,10,11,12
Whats new in Java 9,10,11,12Whats new in Java 9,10,11,12
Whats new in Java 9,10,11,12
 
Java 8 Lambda
Java 8 LambdaJava 8 Lambda
Java 8 Lambda
 

More from Simone Bordet

More from Simone Bordet (6)

Java 13 Updates
Java 13 UpdatesJava 13 Updates
Java 13 Updates
 
Java 9 - Part 2: Jigsaw Modules
Java 9 - Part 2: Jigsaw ModulesJava 9 - Part 2: Jigsaw Modules
Java 9 - Part 2: Jigsaw Modules
 
G1 Garbage Collector: Details and Tuning
G1 Garbage Collector: Details and TuningG1 Garbage Collector: Details and Tuning
G1 Garbage Collector: Details and Tuning
 
Servlet 3.1 Async I/O
Servlet 3.1 Async I/OServlet 3.1 Async I/O
Servlet 3.1 Async I/O
 
HTTP/2 and Java: Current Status
HTTP/2 and Java: Current StatusHTTP/2 and Java: Current Status
HTTP/2 and Java: Current Status
 
Cloud-Ready Web Messaging with CometD
Cloud-Ready Web Messaging with CometDCloud-Ready Web Messaging with CometD
Cloud-Ready Web Messaging with CometD
 

Recently uploaded

+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 

Recently uploaded (20)

W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 

Java 9/10/11 - What's new and why you should upgrade

  • 1. sbordet@webtide.com Java 9/10/11 What’s new and why you should upgrade @simonebordet
  • 2. sbordet@webtide.com Simone Bordet ● @simonebordet ● sbordet@webtide.com ● Java Champion ● Works @ Webtide ○ The company behind Jetty and CometD
  • 3. sbordet@webtide.com Java 11 ● Java 11 is here! ● “Long Term Support” (LTS) Release ○ Java 8 was the previous LTS Release ○ Java 9 and Java 10 already unmaintained
  • 4. sbordet@webtide.com Java 11 OpenJDK 11 Repository https://hg.openjdk.java.net Oracle JDK Binary https://java.oracle.com OpenJDK Binary http://jdk.java.net/11 RedHat JDK Binary Azul JDK Binary (Zulu) AdoptOpenJDK Binary https://adoptopenjdk.net
  • 5. sbordet@webtide.com Java 11 ● What does LTS really mean? ● During the 6 months of “life” of a Java 11: ○ OpenJDK Binary -> GPL ○ AdoptOpenJDK -> GPL ○ Azul Zulu -> GPL ○ Oracle JDK Binary -> Oracle License ■ MUST PAY Oracle for production use
  • 6. sbordet@webtide.com Java 11 ● After the 6 months of “life” of a Java 11: ○ Upgrade to Java 12 ○ Stay on Java 11
  • 7. sbordet@webtide.com ● After 6 months, you stay on Java 11 ○ Never update -> exposed to vulnerabilities ○ Update Java 11 -> 11.0.x ● Community (RedHat) backports fixes ● Vendors create binary builds ○ AdoptOpenJDK -> GPL ○ Other vendors (Oracle, Azul, RedHat, …) -> PAY Java 11
  • 9. sbordet@webtide.com Java 9 ● Java 9 introduced the Java Module System ● Along with it, a number of breaking changes ○ Upgrading from 8 to 9/10/11 is NOT simple ○ Many runtime behavior changes ○ Needs very thorough testing
  • 10. sbordet@webtide.com Java 9 ● Removed tools.jar ○ Attach API, Compiler API, JavaDoc API, etc. ● Removed JavaDB ● Removed endorsed and extension directories ○ $JAVA_HOME/lib/endorsed ○ $JAVA_HOME/jre/lib/ext
  • 11. sbordet@webtide.com Java 9 ● Class loading implementation changed ○ Different behavior to support modules ClassLoader sysCL = ClassLoader.getSystemClassLoader(); // Throws ClassCastException now! URLClassLoader urlCL = (URLClassLoader)sysCL;
  • 12. sbordet@webtide.com Java 9 ● Loading resources URL resource = sysCL.getResource("java/lang/String.class"); // Not a file:/ nor a jar:/ URL! resource = jrt:/java.base/java/lang/String.class URL resource = sysCL.getResource("/com/foo/bar.properties"); // It’s there, but it won’t find it! resource = null;
  • 13. sbordet@webtide.com Java 9 ● New version string scheme ○ 1.8.0_181 -> 9.0.1 ○ Broke many Maven Plugins, Jetty, etc. ● JDK 9’s java.lang.Runtime.Version class ○ Cannot parse JDK 8 version string ○ Must implement custom parsing to support both
  • 14. sbordet@webtide.com Java 9 ● Internal APIs encapsulated ○ Cannot access sun.* or com.sun.* classes ● Finalization ○ sun.misc.Cleaner -> java.lang.ref.Cleaner ○ Object.finalize() -> deprecated ● Unsafe ○ Some sun.misc.Unsafe usage replaced by VarHandle
  • 15. sbordet@webtide.com Java 9 ● Multi Release jars com/ acme/ A.class B.class META-INF/ versions/ 9/ com/ acme/ A.class <- Replaces normal A.class C.class
  • 16. sbordet@webtide.com Java 9 ● Variable Handles ○ Expose some Unsafe functionality class ConcurrentLinkedQueue_BAD { // BAD, adds indirection AtomicReference<Node> head; }
  • 17. sbordet@webtide.com Java 9 class ConcurrentLinkedQueue { private Node head; private static final VarHandle HEAD; static { HEAD = MethodHandles.lookup() .findVarHandle(ConcurrentLinkedQueue.class, "head", Node.class); } public void m() { if (HEAD.compareAndSet(...)) ... } } }
  • 18. sbordet@webtide.com Java 9 ● Process APIs Process p = new ProcessBuilder() .command("java") .directory(new File("/tmp")) .redirectOutput(Redirect.DISCARD) .start(); ProcessHandle.of(p.pid()) .orElseThrow(IllegalStateException::new) .onExit() .thenAccept(h -> System.err.printf("%d exited%n", h.pid()) );
  • 19. sbordet@webtide.com Java 9 ● Concurrent APIs Enhancements ○ java.util.concurrent.Flow ■ Identical APIs and semantic of ReactiveStreams ○ CompletableFuture enhancements ■ Common scheduler for timeout functionalities CompletableFuture.supplyAsync(() -> longJob()) .completeOnTimeout("N/A", 1, TimeUnit.SECONDS) CompletableFuture.supplyAsync(() -> longJob()) .orTimeout(1, TimeUnit.SECONDS)
  • 20. sbordet@webtide.com Java 9 ● jshell - Read-Eval-Print-Loop (REPL) ● Pretty powerful! ○ AutoCompletion, Imports, Javadocs ○ History, search ○ Syncs with external editor ○ Function and forward references ○ ...
  • 21. sbordet@webtide.com Java 9 ● G1 is the default Garbage Collector ● Much improved from 8 and even better in 11 ○ Adaptive start of concurrent mark ○ Made internal data structures more concurrent ○ More phases parallelized ○ Reduced contention ○ Reduced memory consumption
  • 22. sbordet@webtide.com Java 9 ● Unified GC logging ○ Not compatible with previous GC logs ● Every GC logs differently ● Example ○ - Xlog:gc*,ergo*=trace,ref*=debug:file=log s/gc.log:time,level,tags
  • 23. sbordet@webtide.com Java 9 ● JVM options changes ○ 50 options removed - JVM refuses to start ○ 18 options ignored - 12 options deprecated ● Must review your command line! ○ Especially if you had custom GC tuning options
  • 25. sbordet@webtide.com Java 10 ● Local variable type inference (a.k.a. var) ○ http://openjdk.java.net/projects/amber/LVTIstyle.html // Infers ArrayList<String> var list = new ArrayList<String>(); // infers Stream<String> var stream = list.stream();
  • 26. sbordet@webtide.com Java 10 ● var is not a keyword, it is a reserved type name ○ It’s a valid identifier, unless used in places where the compiler expects a type name int var = 13;
  • 27. sbordet@webtide.com Java 10 ● Good var usage var message = "warning, too many features"; var anon = new Object() { int count = 0; } anon.count++; // Compiles!
  • 28. sbordet@webtide.com Java 10 ● Controversial var usage // What type ? var result = processor.run(); // IDE cannot help you var list = new <ctrl+space>
  • 29. sbordet@webtide.com Java 10 ● Experimental Graal JIT ○ https://www.graalvm.org/ ● -XX:+UnlockExperimentalVMOptions -XX: +UseJVMCICompiler ● Not yet recommended in production ○ Twitter uses it in production, you may too (YMMV)
  • 30. sbordet@webtide.com Java 10 ● Docker awareness ○ On by default ○ https://blog.docker.com/2018/04/improved-docker-containe -XX:-UseContainerSupport -XX:ActiveProcessorCount=n -XX:MinRAMPercentage=p -XX:InitialRAMPercentage=p -XX:MaxRAMPercentage=p
  • 32. sbordet@webtide.com Java 11 ● Two new Garbage Collectors ○ Epsilon GC ○ ZGC ● Epsilon GC ○ No-operation GC
  • 33. sbordet@webtide.com ● ZGC ○ 5 years of closed source development @ Oracle ○ XX:+UnlockExperimentalVMOptions XX:+UseZGC ○ Single Generation, Region Based ○ Concurrent Marking ○ Concurrent Compaction ○ Very low STW pause times Java 11
  • 34. sbordet@webtide.com Java 11 ● Removed methods ○ Thread.stop(Throwable) ○ Thread.destroy() ○ System.runFinalizersOnExit(boolean) ○ Some SecurityManager.check*() methods
  • 35. sbordet@webtide.com Java 11 ● Removed modules ○ java.activation (JAF) ○ java.corba ○ java.transaction (JTA) ○ java.xml.bind (JAXB) ○ java.xml.ws (JAX-WS) ○ java.xml.ws.annotation (@PostConstruct, ...) ● Replaced by standalone jars ○ https://dzone.com/articles/apis-to-be-removed-from-java-11
  • 36. sbordet@webtide.com Java 11 ● Java Flight Recorder ○ Open Sourced by Oracle, included in OpenJDK 11 ○ java -XX:StartFlightRecording ... ● Java Mission Control ○ Open Sourced by Oracle ○ Downloads at https://jdk.java.net/jmc/ ○ JMC 7 scheduled for January 2019
  • 37. sbordet@webtide.com Java 11 ● TLS 1.3 ○ More secure and recent version of TLS ○ Removed vulnerable/weak ciphers ○ Added new ciphers and algorithms ● Using SSLEngine? Verify it works!
  • 38. sbordet@webtide.com Java 11 ● Launch Single-File Source-Code programs $ java Hello.java ● Compiled in-memory with Graal ● Teaching ● Java Scripts
  • 39. sbordet@webtide.com Java 11 ● HTTP client ○ Supports both HTTP/1.1 and HTTP/2 ○ Based on the j.u.c.Flow APIs HttpClient c = HttpClient.newBuilder().build(); HttpRequest r = HttpRequest.newBuilder() .uri(...).build(); CompletableFuture<String> f = c.sendAsync(r, BodyHandlers.ofString());
  • 40. sbordet@webtide.com Java 11 ● Nest Mates ○ Inner (nested) classes introduced in Java 1.1 ○ Outer class can access inner class ■ Via compiler tricks - bridge methods java.lang.UnsupportedOperationException at NestExample.init(NestExample.java) at NestExample.access$000(NestExample.java) at NestExample$Inner.(NestExample.java) at NestExample.main(NestExample.java)
  • 41. sbordet@webtide.com Java 11 ● Nest Mates ○ Now specified in the JVM Specification ○ New class file attribute ○ New reflection APIs: Class.getNestMembers(), ... ○ New JVM access controls at runtime ● Do you play with bytecode? ○ Use ASM 7+
  • 43. sbordet@webtide.com Conclusions ● Upgrade from Java 8 takes time ○ Lots of runtime changes ● Java 8 will be soon unmaintained / unavailable ○ Skip Java 9 and Java 10 - go straight to Java 11 ● Lots of good stuff and more coming ○ And coming every 6 months now!