SlideShare a Scribd company logo
Java 9/10
What’s New
Simone Bordet
● @simonebordet
● sbordet@webtide.com
● Java Champion
● Works @ Webtide
● The company behind Jetty and CometD
● JVM Tuning Expert
Java 9
● Java 9 & 10 are NOTLong Term Support (LTS) Releases
● Java 8 current LTS Release supported March 2014 - January 2019
● Java 9 supported September 2017 - March 2018
● Java 10 supported March 2018 - September 2018
● Java 11 new LTS Release September 2018
● But “LTS” has a special meaning
Java 9
● “Long Term Support” is only for Oracle customers
● For Oracle customers Java 11 will be supported for 3 years
● For all the others Java 11 will last the usual 6 months only
● You will be “Long Term Supported” by moving to Java 12
● Other JDK vendors may give you support where Oracle does not
○ Azul, RedHat, London Java Community (LJC), etc.
https://www.azul.com/products/zulu-and-zulu-enterprise/zulu-enterprise-java-support-options/
Java 9
● Java 9 comes with a MASSIVE number of changes
○ 91 JEPs (!)
● Biggest change: Jigsaw modules
● Upgrade to Java 9 not as smooth as past JDKs
○ Needs very thorough testing
● Removed tools.jar
○ Attach APIs
○ Programmatically call javac (JSP compilation), javadoc, etc.
● tools.jar content split into packages
○ jdk.attach
○ jdk.compiler (but use module java.compiler)
○ jdk.javadoc
● Removed JavaDB
○ Rebranding of Apache Derby
Java 9 Removals
Java 9 Removals
● Removed endorsed directory mechanism
$JAVA_HOME/lib/endorsed
● Could only contain updates for:
○ CORBA
○ XML DOM
○ XML SAX
● Rarely used to update the implementations shipped with the JDK
Java 9 Removals
● Removed Extension Directory Mechanism
○ Moved to modules
$JAVA_HOME/jre/lib/ext
nashorn.jar
jfxrt.jar
sunec.jar
sunjce_provider.jar
zipfs.jar
...
Java 9 Changes
● ClassLoader Hierarchy
● Java 8
Boot CL <- Extension CL <- System CL
ClassLoader.getSystemClassLoader()
● Java 9
Boot CL <- Platform CL <- System CL
ClassLoader.getPlatformClassLoader()
ClassLoader.getSystemClassLoader()
Java 9 Changes
● ClassLoading Implementation Changes
// Throws ClassCastException now!
URLClassLoader system = (URLClassLoader)ClassLoader.getSystemClassLoader();
● ClassLoader Resources
URL resource = system.getResource("java/lang/String.class");
resource = jrt:/java.base/java/lang/String.class
● Class scanning for annotations
○ Previous techniques not working in JDK 9
○ Cannot retrieve the list of jars to open
Java 9 Changes
● JEP 223 - New Version String Scheme
○ System.getProperty("java.version")
○ 1.8.0_152 -> 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
Java 9 New Features
● JEP 260 - Encapsulate Internal APIs
● Non-critical internal APIs have been removed
○ sun.misc.Base64Decoder
● Critical internal APIs without replacement -> retained
○ In module jdk.unsupported
○ For example, sun.misc.Unsafe
○ Don’t use them
● Critical internal APIs with replacement -> encapsulated
○ Use the replacements
Java 9 New Features
● JEP 260 - Encapsulate Internal APIs
● Most internal APIs now have a public replacement
● Finalization
○ sun.misc.Cleaner replaced by java.lang.ref.Cleaner
○ Object.finalize() is now deprecated
● Unsafe access
○ Some sun.misc.Unsafe usage replaced by VarHandle
Java 9 New Features
● JEP 260 - Encapsulate Internal APIs
● jdeps tool produces a report of class/jar/module dependencies
$ jdeps -s jetty-util-9.4.8-SNAPSHOT.jar
jetty-util-9.4.8-SNAPSHOT.jar -> java.base
jetty-util-9.4.8-SNAPSHOT.jar -> java.desktop
jetty-util-9.4.8-SNAPSHOT.jar -> java.logging
jetty-util-9.4.8-SNAPSHOT.jar -> java.naming
jetty-util-9.4.8-SNAPSHOT.jar -> java.sql
jetty-util-9.4.8-SNAPSHOT.jar -> java.xml
jetty-util-9.4.8-SNAPSHOT.jar -> not found
Java 9 New Features
● JEP 247 - Compile for older platforms
● New switch --release to javac
○ Supports up to 3 previous releases
● $JAVA_HOME/lib/ct.sym
○ Zipped file containing the symbols for each platform
Java 9 New Features
<profile>
<id>jdk9</id>
<activation>
<jdk>[1.9,)</jdk>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.0+</version>
<configuration>
<release>8</release>
</configuration>
</plugin>
</plugins>
</build>
</profile>
Java 9 New Features
● JEP 238 - Multi Release jars
com/
acme/
A.class
B.class
C.class
META-INF/
versions/
9/
com/
acme/
A.class
D.class
Java 9 Changes
● URLStreamHandler
● Java 8: Magic Reflection
○ sun.net.www.protocol.<scheme>.Handler
● Java 9: ServiceLoader
○ Implement java.net.spi.URLStreamHandlerProvider
● Difficult to make a jar with both solutions
○ Service files cannot be versioned
Java 9 New Features
● JEP 213 - Small Language Changes
● Cannot use "_" as identifier
○ Object _ = new Object();
● Improved type inference
○ Use diamond notation in anonymous inner classes
● Private methods in interfaces
○ Useful to AOP frameworks
○ Avoids code duplications in default methods
Java 9 New Features
● JEP 213 - Small Language Changes
● Enhanced try-with-resources
InputStream input = ...;
...
try (input) {
...
}
Java 9 New Features
● JEP 264 - Platform Logging APIs
○ Implementation defaults to java.util.logging
System.getLogger("name")
.log(Level.INFO, () -> "a" + " - " + "b");
System.getLogger("name")
.log(Level.INFO, "%s - %s", a, b);
Java 9 New Features
● JEP 254 - Compact Strings
○ java.lang.String now stores a byte[], not a char[]
● JEP 280 - String concatenation using invokedynamic
○ Faster and allocates less
● JEP 269 - Collections factory methods
○ Space efficient
List.of("a", "b", "c");
Set.of("a", "b", "c");
Map.of("a", 1, "b", 2, "c", 3);
Java 9 New Features
● JEP 193 - Variable Handles
class ConcurrentLinkedQueue_BAD {
AtomicReference<Node> head; // BAD, adds indirection
}
class ConcurrentLinkedQueue {
Node head;
private static final VarHandle HEAD;
static {
HEAD = MethodHandles.lookup()
.findVarHandle(ConcurrentLinkedQueue.class, "head", Node.class);
}
public void m() {
if (HEAD.compareAndSet(...))
...
}
}
Java 9 New Features
● JEP 102 - Process API
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())
);
Java 9 New Features
● JEP 266 - Concurrent APIs Enhancements
● java.util.concurrent.Flow
○ Identical API 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)
● JEP 143 - Improve Contended Locking
○ synchronized now as scalable as java.util.concurrent.Lock
http://vmlens.com/articles/performance-improvements-of-java-monitor/
Java 9 Changes
Java 9 New Features
● JEP 295: Ahead-of-Time Compilation
○ Experimental
○ Based on the Java-based Graal JIT compiler
https://mjg123.github.io/2017/10/02/JVM-startup.html
Java 9 New Features
● JEP 222 - jshell Read-Eval-Print-Loop (REPL)
○ Can be accessed programmatically via module jdk.jshell
● Pretty powerful !
○ Completion
○ Imports
○ Variable creation
○ Documentation
○ Functions and Forward References
○ History
○ Search
○ External Editor
Java 9 Changes
● JEP 248 - Make G1 the Default Collector
● 250+ Improvements
○ Adaptive start of concurrent mark -XX:+G1UseAdaptiveIHOP
○ Made internal data structures more concurrent
○ More phases parallelized
○ Reduced contention
○ Reduced memory consumption
○ …
● 180+ Bug Fixes
Java 9 Changes
● JEP 158 - Unified JVM Logging
● Logs have a message, tags (finally) and a level; can be decorated
● Tags
○ gc, ref, ergo, …
● Levels
○ error, warning, info, debug, trace
● Output
○ stdout, stderr, file
● Decorators
○ time (various formats), pid, tid, level, tags
● Default
○ -Xlog:all=warning:stderr:uptime,level,tags
Java 9 Changes
● JEP 271 - Unified GC Logging
○ Done using JEP 158 - Unified JVM Logging
● Example for GC logging
○ -Xlog:gc*,ergo*=trace,ref*=debug:file=logs/gc.log:time,level,tags
● Not compatible with previous logging formats
○ Need to parse the logs differently
Java 9 Changes
● JVM Options Changes
○ 50 Removed - JVM refuses to start
○ 18 Ignored, 12 Deprecated
● Important JVM Options Removed
○ GCLogFileSize
○ NumberOfGCLogFiles
○ PrintAdaptiveSizePolicy
○ PrintGCApplicationStoppedTime
○ PrintGCCause
○ PrintGCDateStamps
○ PrintGCTimeStamps
○ PrintReferenceGC
○ PrintTenuringDistribution
○ ...
Java 9 Changes
● JEP 277 - Enhanced Deprecation
@Deprecated(since="1.8", forRemoval=true)
● jdeprscan
○ Produces a report of deprecations
Java 9 Changes
● JEP 229 - Keystore Defaults to PKCS12
● PKCS12
○ Standard format, more secure, more extensible
○ Already supported in JDK 8
● JDK 9
○ keytool by default creates PKCS12 keystores
○ Autodetects JKS and PKCS12 keystores
Java 9 New Features
● JEP 219 - Datagram Transport Layer Security (DTLS)
● JEP 244 - TLS Application-Layer Protocol Negotiation Extension (ALPN)
● JEP 246 - Leverage CPU Instructions for GHASH and RSA
● JEP 249 - OCSP Stapling for TLS
● JEP 273 - DRBG-Based SecureRandom Implementations
● JEP 287 - SHA-3 Hash Algorithms
● JEP 288 - Disable SHA-1 Certificates
Java 10
● Parallel full GC for G1
● In Java 9, if G1 must perform a full GC it’s single threaded
○ Very slow
● In Java 10, it has been parallelized
[5.423s] GC(59) Pause Full 4028M->3286M(4096M) 513.026ms
[5.423s] GC(59) User=2.80s Sys=0.04s Real=0.52s
Java 10
● Experimental Graal JIT
○ https://www.graalvm.org/
● -XX:+UnlockExperimentalVMOptions -XX:+UseJVMCICompiler
● Not yet recommended in production
Java 10
● Application class-data sharing
○ https://blog.codefx.org/java/application-class-data-sharing/
● -Xshare:dump
○ Dumps JDK classes
○ Faster startup times
$ java
-XX:+UseAppCDS
-Xshare:dump
-XX:SharedClassListFile=classes.lst
-XX:SharedArchiveFile=app-cds.jsa
--class-path app.jar
Java 10
● Thread-Local Handshakes
● Improves JVM performance
○ Reduces Time-To-SafePoint (TTSP)
● No need to have a global SafePoint to get stack traces
○ Great benefit to profilers for stack sampling
Java 10
● Docker awareness (Linux only)
○ https://blog.docker.com/2018/04/improved-docker-container-integration-with-java-10/
○ It is on by default
● -XX:-UseContainerSupport
● -XX:ActiveProcessorCount=n
● -XX:MinRAMPercentage=p
● -XX:InitialRAMPercentage=p
● -XX:MaxRAMPercentage=p
Java 10
● Planned removals for JDK 11
● java.corba (CORBA)
● java.xml.bind (JAXB)
● java.xml.ws (SOAP)
● java.xml.ws.annotation (@PostConstruct, @PreDestroy, ...)
Java 10
● Local variable type inference (a.k.a. var)
○ http://openjdk.java.net/projects/amber/LVTIstyle.html
var list = new ArrayList<String>(); // infers ArrayList<String>
var stream = list.stream(); // infers Stream<String>
● 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;
Java 10
● var comes with some controversy
var message = "warning, too many features"; // Good
● Consider:
List<String> list = new ArrayList<>();
list.trimToSize(); // Does not compile
var list = new ArrayList<String>();
list.trimToSize(); // Compiles
Java 10
● More controversy:
var result = processor.run(); // What type ?
var list = new <ctrl+space> // IDE cannot help you
Java 9/10 Migration
● Migrating to Java 9/10 is an iterative process
○ Typically cannot be done in one step only
● Update dependencies
○ Build tools
○ Libraries
● Run jdeps -jdkinternals
● Fix usages of encapsulated APIs
● Using EE modules ?
● Add --add-modules to command line
Java 9/10 Migration
● Update command line options
● Fix GC logging
● Fix your System.getProperty("java.version") usages
● Do not do deep reflection on JDK classes
○ Do not use setAccessible(true);
● Verify your ClassLoader usages
● Verify your sun.* usages
Java 9/10 Migration
● Java 9 upgrade may introduce different behaviors at runtime
● Java code may throw exceptions when running in Java 9
○ Parsing of "java.version"
○ Playing with ClassLoaders and resources
○ URLStreamHandlers
○ Use of internal APIs
○ Etc.
● You can only discover these incompatibilities by extensive testing
○ Requires time to do, so start immediately !
Questions ?

More Related Content

What's hot (20)

PDF
JDK9 Features (Summary, 31/Jul/2015) #JJUG
Yuji Kubota
 
PDF
De Java 8 a Java 11 y 14
Víctor Leonel Orozco López
 
PDF
java8-features
Sascha Koch
 
PDF
Adding replication protocol support for psycopg2
Alexander Shulgin
 
PPT
Find bottleneck and tuning in Java Application
guest1f2740
 
PDF
Lessons Learned: Troubleshooting Replication
Sveta Smirnova
 
PDF
De Java 8 ate Java 14
Víctor Leonel Orozco López
 
PDF
What’s the Best PostgreSQL High Availability Framework? PAF vs. repmgr vs. Pa...
ScaleGrid.io
 
PDF
配置Golden gate同步ddl语句
maclean liu
 
PPTX
자바 성능 강의
Terry Cho
 
PPTX
ClassLoader Leaks
Mattias Jiderhamn
 
PDF
MySQL Replication Troubleshooting for Oracle DBAs
Sveta Smirnova
 
PDF
Embedded systems
Katy Anton
 
PDF
What's new in MySQL 5.6
Shlomi Noach
 
PDF
Dropwizard
Tetiana Saputo
 
PPTX
JDK 9 and JDK 10 Deep Dive
Simon Ritter
 
PDF
The Full MySQL and MariaDB Parallel Replication Tutorial
Jean-François Gagné
 
PDF
Java 8 -12: da Oracle a Eclipse. Due anni e una rivoluzione
ThinkOpen
 
PDF
Managing and Visualizing your Replication Topologies with Orchestrator
Shlomi Noach
 
PDF
MySQL Parallel Replication: inventory, use-case and limitations
Jean-François Gagné
 
JDK9 Features (Summary, 31/Jul/2015) #JJUG
Yuji Kubota
 
De Java 8 a Java 11 y 14
Víctor Leonel Orozco López
 
java8-features
Sascha Koch
 
Adding replication protocol support for psycopg2
Alexander Shulgin
 
Find bottleneck and tuning in Java Application
guest1f2740
 
Lessons Learned: Troubleshooting Replication
Sveta Smirnova
 
De Java 8 ate Java 14
Víctor Leonel Orozco López
 
What’s the Best PostgreSQL High Availability Framework? PAF vs. repmgr vs. Pa...
ScaleGrid.io
 
配置Golden gate同步ddl语句
maclean liu
 
자바 성능 강의
Terry Cho
 
ClassLoader Leaks
Mattias Jiderhamn
 
MySQL Replication Troubleshooting for Oracle DBAs
Sveta Smirnova
 
Embedded systems
Katy Anton
 
What's new in MySQL 5.6
Shlomi Noach
 
Dropwizard
Tetiana Saputo
 
JDK 9 and JDK 10 Deep Dive
Simon Ritter
 
The Full MySQL and MariaDB Parallel Replication Tutorial
Jean-François Gagné
 
Java 8 -12: da Oracle a Eclipse. Due anni e una rivoluzione
ThinkOpen
 
Managing and Visualizing your Replication Topologies with Orchestrator
Shlomi Noach
 
MySQL Parallel Replication: inventory, use-case and limitations
Jean-François Gagné
 

Similar to Java 9-10 What's New (20)

PDF
Haj 4344-java se 9 and the application server-1
Kevin Sutter
 
PDF
A Journey through the JDKs (Java 9 to Java 11)
Markus Günther
 
PDF
JavaOne 2016: Life after Modularity
DanHeidinga
 
PPTX
Discuss about java 9 with latest features
NexSoftsys
 
PPTX
Real World Java 9 - JetBrains Webinar
Trisha Gee
 
PPTX
What’s expected in Java 9
Gal Marder
 
PPTX
An introduction to Java 9 & Its Features
NexSoftsys
 
PPTX
Real World Java 9
Trisha Gee
 
PDF
How can your applications benefit from Java 9?
EUR ING Ioannis Kolaxis MSc
 
PDF
What to expect from Java 9
Ivan Krylov
 
PDF
How can your applications benefit from Java 9?
EUR ING Ioannis Kolaxis MSc
 
PPTX
Java 9 Functionality and Tooling
Trisha Gee
 
PDF
The Diabolical Developer's Guide to Surviving Java 9
jClarity
 
PPSX
Java9 and the impact on Maven Projects (JFall 2016)
Robert Scholte
 
PPTX
Prepare for JDK 9
haochenglee
 
PDF
Java >= 9
Benjamin Pack
 
PPTX
Real World Java 9
Trisha Gee
 
PDF
Java 9
Alican Akkuş
 
PPTX
Java 9: Deep Dive into Modularity and Dealing with Migration Issues
GlobalLogic Ukraine
 
PDF
Java 9 and Beyond
Mayank Patel
 
Haj 4344-java se 9 and the application server-1
Kevin Sutter
 
A Journey through the JDKs (Java 9 to Java 11)
Markus Günther
 
JavaOne 2016: Life after Modularity
DanHeidinga
 
Discuss about java 9 with latest features
NexSoftsys
 
Real World Java 9 - JetBrains Webinar
Trisha Gee
 
What’s expected in Java 9
Gal Marder
 
An introduction to Java 9 & Its Features
NexSoftsys
 
Real World Java 9
Trisha Gee
 
How can your applications benefit from Java 9?
EUR ING Ioannis Kolaxis MSc
 
What to expect from Java 9
Ivan Krylov
 
How can your applications benefit from Java 9?
EUR ING Ioannis Kolaxis MSc
 
Java 9 Functionality and Tooling
Trisha Gee
 
The Diabolical Developer's Guide to Surviving Java 9
jClarity
 
Java9 and the impact on Maven Projects (JFall 2016)
Robert Scholte
 
Prepare for JDK 9
haochenglee
 
Java >= 9
Benjamin Pack
 
Real World Java 9
Trisha Gee
 
Java 9: Deep Dive into Modularity and Dealing with Migration Issues
GlobalLogic Ukraine
 
Java 9 and Beyond
Mayank Patel
 
Ad

More from Nicola Pedot (13)

PDF
AI, ML e l'anello mancante
Nicola Pedot
 
PDF
Ethic clean
Nicola Pedot
 
PDF
Say No To Dependency Hell
Nicola Pedot
 
PDF
Java al servizio della data science - Java developers' meeting
Nicola Pedot
 
PDF
Jakarta EE 2018
Nicola Pedot
 
PDF
Lazy Java
Nicola Pedot
 
PDF
JavaEE6 my way
Nicola Pedot
 
PDF
Java 8 Overview
Nicola Pedot
 
PDF
BDD & design paradoxes appunti devoxx2012
Nicola Pedot
 
PDF
Tom EE appunti devoxx2012
Nicola Pedot
 
ODP
Eclipse Svn
Nicola Pedot
 
ODP
Eclipse
Nicola Pedot
 
PPT
Presentazione+Android
Nicola Pedot
 
AI, ML e l'anello mancante
Nicola Pedot
 
Ethic clean
Nicola Pedot
 
Say No To Dependency Hell
Nicola Pedot
 
Java al servizio della data science - Java developers' meeting
Nicola Pedot
 
Jakarta EE 2018
Nicola Pedot
 
Lazy Java
Nicola Pedot
 
JavaEE6 my way
Nicola Pedot
 
Java 8 Overview
Nicola Pedot
 
BDD & design paradoxes appunti devoxx2012
Nicola Pedot
 
Tom EE appunti devoxx2012
Nicola Pedot
 
Eclipse Svn
Nicola Pedot
 
Eclipse
Nicola Pedot
 
Presentazione+Android
Nicola Pedot
 
Ad

Recently uploaded (20)

PDF
FINAL ZAKROS - UNESCO SITE CANDICACY - PRESENTATION - September 2024
StavrosKefalas1
 
PDF
Medical Technology Corporation: Supply Chain Strategy
daretruong
 
PDF
CHALLENGIES FACING THEOLOGICAL EDUCATION IN NIGERIA: STRATEGIES FOR IMPROVEMENT
PREVAILERS THEOLOGICAL SCHOOL FCT ABUJA
 
PDF
Generalization predition MOOCs - Conference presentation - eMOOCs 2025
pmmorenom01
 
PPTX
Bob Stewart Humble Obedience 07-13-2025.pptx
FamilyWorshipCenterD
 
PPTX
Pastor Bob Stewart Acts 21 07 09 2025.pptx
FamilyWorshipCenterD
 
PPTX
some leadership theories MBA management.pptx
rkseo19
 
PPTX
BARRIERS TO EFFECTIVE COMMUNICATION.pptx
shraddham25
 
PDF
Cloud Computing Service Availability.pdf
chakrirocky1
 
PDF
Leveraging the Power of Jira Dashboard.pdf
siddharthshukla742740
 
PPTX
2025-07-13 Abraham 07 (shared slides).pptx
Dale Wells
 
PPTX
STURGEON BAY WI AG PPT JULY 6 2025.pptx
FamilyWorshipCenterD
 
PDF
The Family Secret (essence of loveliness)
Favour Biodun
 
PPTX
g1-oral-comm-1.pptx dkekekwkwoowowwkkrkrrkfkfkfm
hnanie845
 
PPTX
677697609-States-Research-Questions-Final.pptx
francistiin8
 
PPTX
Presentationexpressions You are student leader and have just come from a stud...
BENSTARBEATZ
 
PPTX
AI presentation for everyone in every fields
dodinhkhai1
 
PPTX
A brief History of counseling in Social Work.pptx
Josaya Injesi
 
PDF
What should be in a Leadership and Motivation Plan?
Writegenic AI
 
PPTX
Inspired by VeinSense: Supercharge Your Hackathon with Agentic AI
ShubhamSharma2528
 
FINAL ZAKROS - UNESCO SITE CANDICACY - PRESENTATION - September 2024
StavrosKefalas1
 
Medical Technology Corporation: Supply Chain Strategy
daretruong
 
CHALLENGIES FACING THEOLOGICAL EDUCATION IN NIGERIA: STRATEGIES FOR IMPROVEMENT
PREVAILERS THEOLOGICAL SCHOOL FCT ABUJA
 
Generalization predition MOOCs - Conference presentation - eMOOCs 2025
pmmorenom01
 
Bob Stewart Humble Obedience 07-13-2025.pptx
FamilyWorshipCenterD
 
Pastor Bob Stewart Acts 21 07 09 2025.pptx
FamilyWorshipCenterD
 
some leadership theories MBA management.pptx
rkseo19
 
BARRIERS TO EFFECTIVE COMMUNICATION.pptx
shraddham25
 
Cloud Computing Service Availability.pdf
chakrirocky1
 
Leveraging the Power of Jira Dashboard.pdf
siddharthshukla742740
 
2025-07-13 Abraham 07 (shared slides).pptx
Dale Wells
 
STURGEON BAY WI AG PPT JULY 6 2025.pptx
FamilyWorshipCenterD
 
The Family Secret (essence of loveliness)
Favour Biodun
 
g1-oral-comm-1.pptx dkekekwkwoowowwkkrkrrkfkfkfm
hnanie845
 
677697609-States-Research-Questions-Final.pptx
francistiin8
 
Presentationexpressions You are student leader and have just come from a stud...
BENSTARBEATZ
 
AI presentation for everyone in every fields
dodinhkhai1
 
A brief History of counseling in Social Work.pptx
Josaya Injesi
 
What should be in a Leadership and Motivation Plan?
Writegenic AI
 
Inspired by VeinSense: Supercharge Your Hackathon with Agentic AI
ShubhamSharma2528
 

Java 9-10 What's New

  • 2. Simone Bordet ● @simonebordet ● [email protected] ● Java Champion ● Works @ Webtide ● The company behind Jetty and CometD ● JVM Tuning Expert
  • 3. Java 9 ● Java 9 & 10 are NOTLong Term Support (LTS) Releases ● Java 8 current LTS Release supported March 2014 - January 2019 ● Java 9 supported September 2017 - March 2018 ● Java 10 supported March 2018 - September 2018 ● Java 11 new LTS Release September 2018 ● But “LTS” has a special meaning
  • 4. Java 9 ● “Long Term Support” is only for Oracle customers ● For Oracle customers Java 11 will be supported for 3 years ● For all the others Java 11 will last the usual 6 months only ● You will be “Long Term Supported” by moving to Java 12 ● Other JDK vendors may give you support where Oracle does not ○ Azul, RedHat, London Java Community (LJC), etc.
  • 6. Java 9 ● Java 9 comes with a MASSIVE number of changes ○ 91 JEPs (!) ● Biggest change: Jigsaw modules ● Upgrade to Java 9 not as smooth as past JDKs ○ Needs very thorough testing
  • 7. ● Removed tools.jar ○ Attach APIs ○ Programmatically call javac (JSP compilation), javadoc, etc. ● tools.jar content split into packages ○ jdk.attach ○ jdk.compiler (but use module java.compiler) ○ jdk.javadoc ● Removed JavaDB ○ Rebranding of Apache Derby Java 9 Removals
  • 8. Java 9 Removals ● Removed endorsed directory mechanism $JAVA_HOME/lib/endorsed ● Could only contain updates for: ○ CORBA ○ XML DOM ○ XML SAX ● Rarely used to update the implementations shipped with the JDK
  • 9. Java 9 Removals ● Removed Extension Directory Mechanism ○ Moved to modules $JAVA_HOME/jre/lib/ext nashorn.jar jfxrt.jar sunec.jar sunjce_provider.jar zipfs.jar ...
  • 10. Java 9 Changes ● ClassLoader Hierarchy ● Java 8 Boot CL <- Extension CL <- System CL ClassLoader.getSystemClassLoader() ● Java 9 Boot CL <- Platform CL <- System CL ClassLoader.getPlatformClassLoader() ClassLoader.getSystemClassLoader()
  • 11. Java 9 Changes ● ClassLoading Implementation Changes // Throws ClassCastException now! URLClassLoader system = (URLClassLoader)ClassLoader.getSystemClassLoader(); ● ClassLoader Resources URL resource = system.getResource("java/lang/String.class"); resource = jrt:/java.base/java/lang/String.class ● Class scanning for annotations ○ Previous techniques not working in JDK 9 ○ Cannot retrieve the list of jars to open
  • 12. Java 9 Changes ● JEP 223 - New Version String Scheme ○ System.getProperty("java.version") ○ 1.8.0_152 -> 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
  • 13. Java 9 New Features ● JEP 260 - Encapsulate Internal APIs ● Non-critical internal APIs have been removed ○ sun.misc.Base64Decoder ● Critical internal APIs without replacement -> retained ○ In module jdk.unsupported ○ For example, sun.misc.Unsafe ○ Don’t use them ● Critical internal APIs with replacement -> encapsulated ○ Use the replacements
  • 14. Java 9 New Features ● JEP 260 - Encapsulate Internal APIs ● Most internal APIs now have a public replacement ● Finalization ○ sun.misc.Cleaner replaced by java.lang.ref.Cleaner ○ Object.finalize() is now deprecated ● Unsafe access ○ Some sun.misc.Unsafe usage replaced by VarHandle
  • 15. Java 9 New Features ● JEP 260 - Encapsulate Internal APIs ● jdeps tool produces a report of class/jar/module dependencies $ jdeps -s jetty-util-9.4.8-SNAPSHOT.jar jetty-util-9.4.8-SNAPSHOT.jar -> java.base jetty-util-9.4.8-SNAPSHOT.jar -> java.desktop jetty-util-9.4.8-SNAPSHOT.jar -> java.logging jetty-util-9.4.8-SNAPSHOT.jar -> java.naming jetty-util-9.4.8-SNAPSHOT.jar -> java.sql jetty-util-9.4.8-SNAPSHOT.jar -> java.xml jetty-util-9.4.8-SNAPSHOT.jar -> not found
  • 16. Java 9 New Features ● JEP 247 - Compile for older platforms ● New switch --release to javac ○ Supports up to 3 previous releases ● $JAVA_HOME/lib/ct.sym ○ Zipped file containing the symbols for each platform
  • 17. Java 9 New Features <profile> <id>jdk9</id> <activation> <jdk>[1.9,)</jdk> </activation> <build> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.6.0+</version> <configuration> <release>8</release> </configuration> </plugin> </plugins> </build> </profile>
  • 18. Java 9 New Features ● JEP 238 - Multi Release jars com/ acme/ A.class B.class C.class META-INF/ versions/ 9/ com/ acme/ A.class D.class
  • 19. Java 9 Changes ● URLStreamHandler ● Java 8: Magic Reflection ○ sun.net.www.protocol.<scheme>.Handler ● Java 9: ServiceLoader ○ Implement java.net.spi.URLStreamHandlerProvider ● Difficult to make a jar with both solutions ○ Service files cannot be versioned
  • 20. Java 9 New Features ● JEP 213 - Small Language Changes ● Cannot use "_" as identifier ○ Object _ = new Object(); ● Improved type inference ○ Use diamond notation in anonymous inner classes ● Private methods in interfaces ○ Useful to AOP frameworks ○ Avoids code duplications in default methods
  • 21. Java 9 New Features ● JEP 213 - Small Language Changes ● Enhanced try-with-resources InputStream input = ...; ... try (input) { ... }
  • 22. Java 9 New Features ● JEP 264 - Platform Logging APIs ○ Implementation defaults to java.util.logging System.getLogger("name") .log(Level.INFO, () -> "a" + " - " + "b"); System.getLogger("name") .log(Level.INFO, "%s - %s", a, b);
  • 23. Java 9 New Features ● JEP 254 - Compact Strings ○ java.lang.String now stores a byte[], not a char[] ● JEP 280 - String concatenation using invokedynamic ○ Faster and allocates less ● JEP 269 - Collections factory methods ○ Space efficient List.of("a", "b", "c"); Set.of("a", "b", "c"); Map.of("a", 1, "b", 2, "c", 3);
  • 24. Java 9 New Features ● JEP 193 - Variable Handles class ConcurrentLinkedQueue_BAD { AtomicReference<Node> head; // BAD, adds indirection } class ConcurrentLinkedQueue { Node head; private static final VarHandle HEAD; static { HEAD = MethodHandles.lookup() .findVarHandle(ConcurrentLinkedQueue.class, "head", Node.class); } public void m() { if (HEAD.compareAndSet(...)) ... } }
  • 25. Java 9 New Features ● JEP 102 - Process API 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()) );
  • 26. Java 9 New Features ● JEP 266 - Concurrent APIs Enhancements ● java.util.concurrent.Flow ○ Identical API 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)
  • 27. ● JEP 143 - Improve Contended Locking ○ synchronized now as scalable as java.util.concurrent.Lock http://vmlens.com/articles/performance-improvements-of-java-monitor/ Java 9 Changes
  • 28. Java 9 New Features ● JEP 295: Ahead-of-Time Compilation ○ Experimental ○ Based on the Java-based Graal JIT compiler https://mjg123.github.io/2017/10/02/JVM-startup.html
  • 29. Java 9 New Features ● JEP 222 - jshell Read-Eval-Print-Loop (REPL) ○ Can be accessed programmatically via module jdk.jshell ● Pretty powerful ! ○ Completion ○ Imports ○ Variable creation ○ Documentation ○ Functions and Forward References ○ History ○ Search ○ External Editor
  • 30. Java 9 Changes ● JEP 248 - Make G1 the Default Collector ● 250+ Improvements ○ Adaptive start of concurrent mark -XX:+G1UseAdaptiveIHOP ○ Made internal data structures more concurrent ○ More phases parallelized ○ Reduced contention ○ Reduced memory consumption ○ … ● 180+ Bug Fixes
  • 31. Java 9 Changes ● JEP 158 - Unified JVM Logging ● Logs have a message, tags (finally) and a level; can be decorated ● Tags ○ gc, ref, ergo, … ● Levels ○ error, warning, info, debug, trace ● Output ○ stdout, stderr, file ● Decorators ○ time (various formats), pid, tid, level, tags ● Default ○ -Xlog:all=warning:stderr:uptime,level,tags
  • 32. Java 9 Changes ● JEP 271 - Unified GC Logging ○ Done using JEP 158 - Unified JVM Logging ● Example for GC logging ○ -Xlog:gc*,ergo*=trace,ref*=debug:file=logs/gc.log:time,level,tags ● Not compatible with previous logging formats ○ Need to parse the logs differently
  • 33. Java 9 Changes ● JVM Options Changes ○ 50 Removed - JVM refuses to start ○ 18 Ignored, 12 Deprecated ● Important JVM Options Removed ○ GCLogFileSize ○ NumberOfGCLogFiles ○ PrintAdaptiveSizePolicy ○ PrintGCApplicationStoppedTime ○ PrintGCCause ○ PrintGCDateStamps ○ PrintGCTimeStamps ○ PrintReferenceGC ○ PrintTenuringDistribution ○ ...
  • 34. Java 9 Changes ● JEP 277 - Enhanced Deprecation @Deprecated(since="1.8", forRemoval=true) ● jdeprscan ○ Produces a report of deprecations
  • 35. Java 9 Changes ● JEP 229 - Keystore Defaults to PKCS12 ● PKCS12 ○ Standard format, more secure, more extensible ○ Already supported in JDK 8 ● JDK 9 ○ keytool by default creates PKCS12 keystores ○ Autodetects JKS and PKCS12 keystores
  • 36. Java 9 New Features ● JEP 219 - Datagram Transport Layer Security (DTLS) ● JEP 244 - TLS Application-Layer Protocol Negotiation Extension (ALPN) ● JEP 246 - Leverage CPU Instructions for GHASH and RSA ● JEP 249 - OCSP Stapling for TLS ● JEP 273 - DRBG-Based SecureRandom Implementations ● JEP 287 - SHA-3 Hash Algorithms ● JEP 288 - Disable SHA-1 Certificates
  • 37. Java 10 ● Parallel full GC for G1 ● In Java 9, if G1 must perform a full GC it’s single threaded ○ Very slow ● In Java 10, it has been parallelized [5.423s] GC(59) Pause Full 4028M->3286M(4096M) 513.026ms [5.423s] GC(59) User=2.80s Sys=0.04s Real=0.52s
  • 38. Java 10 ● Experimental Graal JIT ○ https://www.graalvm.org/ ● -XX:+UnlockExperimentalVMOptions -XX:+UseJVMCICompiler ● Not yet recommended in production
  • 39. Java 10 ● Application class-data sharing ○ https://blog.codefx.org/java/application-class-data-sharing/ ● -Xshare:dump ○ Dumps JDK classes ○ Faster startup times $ java -XX:+UseAppCDS -Xshare:dump -XX:SharedClassListFile=classes.lst -XX:SharedArchiveFile=app-cds.jsa --class-path app.jar
  • 40. Java 10 ● Thread-Local Handshakes ● Improves JVM performance ○ Reduces Time-To-SafePoint (TTSP) ● No need to have a global SafePoint to get stack traces ○ Great benefit to profilers for stack sampling
  • 41. Java 10 ● Docker awareness (Linux only) ○ https://blog.docker.com/2018/04/improved-docker-container-integration-with-java-10/ ○ It is on by default ● -XX:-UseContainerSupport ● -XX:ActiveProcessorCount=n ● -XX:MinRAMPercentage=p ● -XX:InitialRAMPercentage=p ● -XX:MaxRAMPercentage=p
  • 42. Java 10 ● Planned removals for JDK 11 ● java.corba (CORBA) ● java.xml.bind (JAXB) ● java.xml.ws (SOAP) ● java.xml.ws.annotation (@PostConstruct, @PreDestroy, ...)
  • 43. Java 10 ● Local variable type inference (a.k.a. var) ○ http://openjdk.java.net/projects/amber/LVTIstyle.html var list = new ArrayList<String>(); // infers ArrayList<String> var stream = list.stream(); // infers Stream<String> ● 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;
  • 44. Java 10 ● var comes with some controversy var message = "warning, too many features"; // Good ● Consider: List<String> list = new ArrayList<>(); list.trimToSize(); // Does not compile var list = new ArrayList<String>(); list.trimToSize(); // Compiles
  • 45. Java 10 ● More controversy: var result = processor.run(); // What type ? var list = new <ctrl+space> // IDE cannot help you
  • 46. Java 9/10 Migration ● Migrating to Java 9/10 is an iterative process ○ Typically cannot be done in one step only ● Update dependencies ○ Build tools ○ Libraries ● Run jdeps -jdkinternals ● Fix usages of encapsulated APIs ● Using EE modules ? ● Add --add-modules to command line
  • 47. Java 9/10 Migration ● Update command line options ● Fix GC logging ● Fix your System.getProperty("java.version") usages ● Do not do deep reflection on JDK classes ○ Do not use setAccessible(true); ● Verify your ClassLoader usages ● Verify your sun.* usages
  • 48. Java 9/10 Migration ● Java 9 upgrade may introduce different behaviors at runtime ● Java code may throw exceptions when running in Java 9 ○ Parsing of "java.version" ○ Playing with ClassLoaders and resources ○ URLStreamHandlers ○ Use of internal APIs ○ Etc. ● You can only discover these incompatibilities by extensive testing ○ Requires time to do, so start immediately !