SlideShare a Scribd company logo
1 of 28
Download to read offline
So, you wanna
migrate to Java9?
by Tomek Adamczewski
13/11/2017
Where are we?
2
Confidential/Restricted/Public
Presentationorparttitle
13/11/2017
Cool features of Java 9
• Project Jigsaw
• JShell
• Enhanced Collections framework
• Enhanced @Deprecated
• Project Coin improvements
• Support for cgroup limits (think: docker)
• G1GC improvements
• Changes to JDK Release Model
3
Confidential/Restricted/Public
Presentationorparttitle
13/11/2017
“Think trains, not limousines”
4
Confidential/Restricted/Public
Presentationorparttitle
13/11/2017
5
Confidential/Restricted/Public
Presentationorparttitle
13/11/2017 Definition of Done
• Code compiles
• New features merged to the master branch
• All tests pass
• The task is documented and closed
1
6
Code
Compiles
jig·saw [jig-saw] n.
a complicated problem consisting of many
different parts
Confidential/Restricted/Public
Presentationorparttitle
13/11/2017
There are no silver bullets
A lot of libraries or plugins are not compatible with Java 9 yet
7
Confidential/Restricted/Public
Presentationorparttitle
13/11/2017
Useful tools
$ jdeps --jdk-internals -R --class-path ‘lib/*’ guava-HEAD-jre-SNAPSHOT.jar
split package: javax.annotation [jrt:/java.xml.ws.annotation, lib/jsr305-1.3.9.jar]
guava-HEAD-jre-SNAPSHOT.jar -> jdk.unsupported
com.google.common.cache.Striped64 -> sun.misc.Unsafe
JDK internal API (jdk.unsupported)
com.google.common.cache.Striped64$1 -> sun.misc.Unsafe
JDK internal API (jdk.unsupported)
(…)
JDK Internal API Suggested Replacement
---------------- ---------------------
sun.misc.Unsafe See http://openjdk.java.net/jeps/260
8
Confidential/Restricted/Public
Presentationorparttitle
13/11/2017
…and hacks
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
- <source>1.8</source>
- <target>1.8</target>
+ <source>9</source>
+ <target>9</target>
+ <compilerArgs>
+ <arg>--add-exports</arg>
+ <arg>java.base/sun.security.jca=ALL-UNNAMED</arg>
+ </compilerArgs>
</configuration>
9
Confidential/Restricted/Public
Presentationorparttitle
13/11/2017
…and hacks
java
① --add-opens java.base/java.lang=ALL-UNNAMED
② --add-modules java.xml.ws.annotation
③ --patch-module java.xml.ws.annotation=jsr305-3.0.2.jar
--class-path $dependencies
-jar $appjar
10
Confidential/Restricted/Public
Presentationorparttitle
13/11/2017
2
11
Code Compiles
New keyword
Confidential/Restricted/Public
Presentationorparttitle
13/11/2017
JEP 302: Lambda Leftovers
Treatment of underscores
In many languages, it is common to use an underscore (_) to denote an unnamed
lambda parameter (and similarly for method and exception parameters):
(…)
Phase 2 came in Java 9, when this warning became an error.
12
Confidential/Restricted/Public
Presentationorparttitle
13/11/2017
BiFunction<Integer, String, String> biss = (i, _) -> String.valueOf(i);
Sonar to the rescue!™
13
Confidential/Restricted/Public
Presentationorparttitle
13/11/2017
Yet another tool to cope with?
14
Confidential/Restricted/Public
Presentationorparttitle
13/11/2017
…not really!
15
Confidential/Restricted/Public
Presentationorparttitle
13/11/2017
3
16
New feature merged
to the master branch
Things might fail or
they might not fail
Confidential/Restricted/Public
Presentationorparttitle
13/11/2017
Enhanced Collections framework
static <K,V> Map<K,V> of()
static <K,V> Map<K,V> of(K k1, V v1)
static <K,V> Map<K,V> of(K k1, V v1, K k2, V v2)
static <K,V> Map<K,V> of(K k1, V v1, K k2, V v2, K k3, V v3)
static <K,V> Map<K,V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5,
K k6, V v6, K k7, V v7, K k8, V v8, K k9, V v9, K k10, V v10)
static <K,V> Map<K,V> ofEntries(Map.Entry<? extends K,? extends V>... entries)
17
Confidential/Restricted/Public
Presentationorparttitle
13/11/2017
Map<String, Integer> fooBar = Map.ofEntries(
entry("foo", 1),
entry("bar", 2),
// (...)
entry("baz", 42));
We’ve all done it before, didn’t we?
@SafeVarargs
public static <K, V> Map<K, V> map(Entry<K, ? extends V>... entries) {
return stream(entries)
.filter(Objects::nonNull)
.collect(toMap(Entry::getKey, Entry::getValue));
}
18
Confidential/Restricted/Public
Presentationorparttitle
13/11/2017
private static final Map<String, ErrorReason> ERROR_REASON_MAPPER =
map(
entry("1001", Format_Incorrect),
entry("1002", Format_Expiry_Date_Incorrect),
// 95 more entries
entry(”6027", Entity_Already_Active));
19
Case studyConfidential/Restricted/Public
Presentationorparttitle
13/11/2017
----------------------------------
BUILD SUCCESS
----------------------------------
Total time: 01:08 min (Wall Clock)
20
Case studyConfidential/Restricted/Public
Presentationorparttitle
13/11/2017
private static final Map<String, ErrorReason> ERROR_REASON_MAPPER =
MapUtils.<String, ErrorReason>map( //explicit generics improve compile time by ~50s
entry("1001", Format_Incorrect),
entry("1002", Format_Expiry_Date_Incorrect),
// 95 more entries
entry(”6027", Entity_Already_Active));
----------------------------------
BUILD SUCCESS
----------------------------------
Total time: 10.556 s (Wall Clock)
Jenkins build-timeout plugin
21
Confidential/Restricted/Public
Presentationorparttitle
13/11/2017
Possible strategies
• Absolute
• Deadline
• Elastic
• Likely stuck
• No Activity
Possible actions
• Abort
• Fail
• Abort and restart
• Write build description
4
22
All tests pass
Things might fail…
but they also might not fail
Confidential/Restricted/Public
Presentationorparttitle
13/11/2017
OptUtils
/** @return ofNullable(t).map(provider).orElseGet(supplier) */
public static <T, R> R optGet(
T t,
Function<T, R> provider,
Supplier<R> supplier) {
return ofNullable(t).map(provider).orElseGet(supplier);
}
23
Confidential/Restricted/Public
Presentationorparttitle
13/11/2017
You can “unit” test your performance
@Test
public void testPerf() throws Exception {
Result result = benchmark(4, 1000,
(thread, pass) -> singlePass(thread, pass));
LOG.info(Table.print(result));
assertExecTimes(result);
}
24
Confidential/Restricted/Public
Presentationorparttitle
13/11/2017
Ugly? But it’s up to 10x faster…
/** @return ofNullable(t).map(provider).orElseGet(supplier) */
public static <T, R> R optGet(
T t,
Function<T, R> provider,
Supplier<R> supplier) {
return t == null ?
supplier.get() :
optGet(provider.apply(t), supplier);
}
/** @return ofNullable(t).orElseGet(supplier) */
public static <T> T optGet(T t, Supplier<T> supplier) {
return t == null ? supplier.get() : t;
}
25
Confidential/Restricted/Public
Presentationorparttitle
13/11/2017
5
26
The task is documented
and closed
In case you just woke up…
Confidential/Restricted/Public
Presentationorparttitle
13/11/2017
Brace yourself
Java WILL be updated every 6 months. Make sure you’re armed and ready
27
Confidential/Restricted/Public
Presentationorparttitle
13/11/2017
CONTACT
tomasz.adamczewski@idemia.com

More Related Content

Viewers also liked

NightClazz Java 8 Decouverte
NightClazz Java 8 DecouverteNightClazz Java 8 Decouverte
NightClazz Java 8 DecouverteZenika
 
The Case for HTTP/2
The Case for HTTP/2The Case for HTTP/2
The Case for HTTP/2Andy Davies
 
Introduction to HTTP/2
Introduction to HTTP/2Introduction to HTTP/2
Introduction to HTTP/2Ido Flatow
 
WTF - What's The Fold - Bordeaux JUG 2013
WTF - What's The Fold - Bordeaux JUG 2013WTF - What's The Fold - Bordeaux JUG 2013
WTF - What's The Fold - Bordeaux JUG 2013Zenika
 
Better Product Definition with Lean UX and Design Thinking
Better Product Definition with Lean UX and Design ThinkingBetter Product Definition with Lean UX and Design Thinking
Better Product Definition with Lean UX and Design ThinkingJeff Gothelf
 
Retours sur java 8 devoxx fr 2016
Retours sur java 8 devoxx fr 2016Retours sur java 8 devoxx fr 2016
Retours sur java 8 devoxx fr 2016Jean-Michel Doudoux
 
Monitoring Compteur EDF avec node.js
Monitoring Compteur EDF avec node.jsMonitoring Compteur EDF avec node.js
Monitoring Compteur EDF avec node.jslaurenthuet
 
Séminaire en ligne - Email Kinetic - 30 Mai 2017
Séminaire en ligne - Email Kinetic - 30 Mai 2017Séminaire en ligne - Email Kinetic - 30 Mai 2017
Séminaire en ligne - Email Kinetic - 30 Mai 2017Experian
 
Conference MicroServices101 - 1ere partie
Conference MicroServices101 - 1ere partieConference MicroServices101 - 1ere partie
Conference MicroServices101 - 1ere partieZenika
 
Going reactive in java
Going reactive in javaGoing reactive in java
Going reactive in javaJosé Paumard
 
Perf ug comment ne plus rajouter de ram a vos jvm sans savoir pourquoi
Perf ug   comment ne plus rajouter de ram a vos jvm sans savoir pourquoiPerf ug   comment ne plus rajouter de ram a vos jvm sans savoir pourquoi
Perf ug comment ne plus rajouter de ram a vos jvm sans savoir pourquoipkernevez
 
Agile Wake Up #1 du 01/12/2015 : L'agilité à grande échelle
Agile Wake Up #1 du 01/12/2015 : L'agilité à grande échelleAgile Wake Up #1 du 01/12/2015 : L'agilité à grande échelle
Agile Wake Up #1 du 01/12/2015 : L'agilité à grande échelleZenika
 
HTTP2 : ce qui va changer par Julien Landuré
HTTP2 : ce qui va changer par Julien LanduréHTTP2 : ce qui va changer par Julien Landuré
HTTP2 : ce qui va changer par Julien LanduréZenika
 
Http2 les impacts dans le web
Http2 les impacts dans le webHttp2 les impacts dans le web
Http2 les impacts dans le webneuros
 
Azure Business rules v0.3
Azure Business rules v0.3Azure Business rules v0.3
Azure Business rules v0.3Luca Mauri
 
Java 9 modulo les modules devoxx fr 2017
Java 9 modulo les modules devoxx fr 2017Java 9 modulo les modules devoxx fr 2017
Java 9 modulo les modules devoxx fr 2017Jean-Michel Doudoux
 

Viewers also liked (20)

NightClazz Java 8 Decouverte
NightClazz Java 8 DecouverteNightClazz Java 8 Decouverte
NightClazz Java 8 Decouverte
 
The Case for HTTP/2
The Case for HTTP/2The Case for HTTP/2
The Case for HTTP/2
 
Introduction to HTTP/2
Introduction to HTTP/2Introduction to HTTP/2
Introduction to HTTP/2
 
WTF - What's The Fold - Bordeaux JUG 2013
WTF - What's The Fold - Bordeaux JUG 2013WTF - What's The Fold - Bordeaux JUG 2013
WTF - What's The Fold - Bordeaux JUG 2013
 
Better Product Definition with Lean UX and Design Thinking
Better Product Definition with Lean UX and Design ThinkingBetter Product Definition with Lean UX and Design Thinking
Better Product Definition with Lean UX and Design Thinking
 
Http2 right now
Http2 right nowHttp2 right now
Http2 right now
 
Retours sur java 8 devoxx fr 2016
Retours sur java 8 devoxx fr 2016Retours sur java 8 devoxx fr 2016
Retours sur java 8 devoxx fr 2016
 
Monitoring Compteur EDF avec node.js
Monitoring Compteur EDF avec node.jsMonitoring Compteur EDF avec node.js
Monitoring Compteur EDF avec node.js
 
Séminaire en ligne - Email Kinetic - 30 Mai 2017
Séminaire en ligne - Email Kinetic - 30 Mai 2017Séminaire en ligne - Email Kinetic - 30 Mai 2017
Séminaire en ligne - Email Kinetic - 30 Mai 2017
 
Conference MicroServices101 - 1ere partie
Conference MicroServices101 - 1ere partieConference MicroServices101 - 1ere partie
Conference MicroServices101 - 1ere partie
 
Going reactive in java
Going reactive in javaGoing reactive in java
Going reactive in java
 
Http2
Http2Http2
Http2
 
Perf ug comment ne plus rajouter de ram a vos jvm sans savoir pourquoi
Perf ug   comment ne plus rajouter de ram a vos jvm sans savoir pourquoiPerf ug   comment ne plus rajouter de ram a vos jvm sans savoir pourquoi
Perf ug comment ne plus rajouter de ram a vos jvm sans savoir pourquoi
 
JavaFX et le JDK9
JavaFX et le JDK9JavaFX et le JDK9
JavaFX et le JDK9
 
Agile Wake Up #1 du 01/12/2015 : L'agilité à grande échelle
Agile Wake Up #1 du 01/12/2015 : L'agilité à grande échelleAgile Wake Up #1 du 01/12/2015 : L'agilité à grande échelle
Agile Wake Up #1 du 01/12/2015 : L'agilité à grande échelle
 
HTTP2 : ce qui va changer par Julien Landuré
HTTP2 : ce qui va changer par Julien LanduréHTTP2 : ce qui va changer par Julien Landuré
HTTP2 : ce qui va changer par Julien Landuré
 
Http2 les impacts dans le web
Http2 les impacts dans le webHttp2 les impacts dans le web
Http2 les impacts dans le web
 
Azure Business rules v0.3
Azure Business rules v0.3Azure Business rules v0.3
Azure Business rules v0.3
 
Java 9 modulo les modules devoxx fr 2017
Java 9 modulo les modules devoxx fr 2017Java 9 modulo les modules devoxx fr 2017
Java 9 modulo les modules devoxx fr 2017
 
Company_Profile_Digital_1
Company_Profile_Digital_1Company_Profile_Digital_1
Company_Profile_Digital_1
 

Similar to Top Tips for Migrating to Java 9

State of GeoServer 2.10
State of GeoServer 2.10State of GeoServer 2.10
State of GeoServer 2.10Jody Garnett
 
Fosdem 2011 - A Common Graph Database Access Layer for .Net and Mono
Fosdem 2011 - A Common Graph Database Access Layer for .Net and MonoFosdem 2011 - A Common Graph Database Access Layer for .Net and Mono
Fosdem 2011 - A Common Graph Database Access Layer for .Net and MonoAchim Friedland
 
JavaOne報告会 Java SE/JavaFX 編 - JJUG CCC 2010 Fall
JavaOne報告会 Java SE/JavaFX 編 - JJUG CCC 2010 FallJavaOne報告会 Java SE/JavaFX 編 - JJUG CCC 2010 Fall
JavaOne報告会 Java SE/JavaFX 編 - JJUG CCC 2010 FallYuichi Sakuraba
 
LocationTech Projects
LocationTech ProjectsLocationTech Projects
LocationTech ProjectsJody Garnett
 
XML-Free Programming : Java Server and Client Development without &lt;>
XML-Free Programming : Java Server and Client Development without &lt;>XML-Free Programming : Java Server and Client Development without &lt;>
XML-Free Programming : Java Server and Client Development without &lt;>Arun Gupta
 
JavaCro 2014 Scala and Java EE 7 Development Experiences
JavaCro 2014 Scala and Java EE 7 Development ExperiencesJavaCro 2014 Scala and Java EE 7 Development Experiences
JavaCro 2014 Scala and Java EE 7 Development ExperiencesPeter Pilgrim
 
DocuOps & Asciidoctor in a JVM World
DocuOps & Asciidoctor in a JVM WorldDocuOps & Asciidoctor in a JVM World
DocuOps & Asciidoctor in a JVM WorldSchalk Cronjé
 
The dark side of Akka and the remedy - bp.scala meetup
The dark side of Akka and the remedy - bp.scala meetupThe dark side of Akka and the remedy - bp.scala meetup
The dark side of Akka and the remedy - bp.scala meetupkrivachy
 
State of GeoServer - FOSS4G 2016
State of GeoServer - FOSS4G 2016State of GeoServer - FOSS4G 2016
State of GeoServer - FOSS4G 2016GeoSolutions
 
Gradle in 45min - JBCN2-16 version
Gradle in 45min - JBCN2-16 versionGradle in 45min - JBCN2-16 version
Gradle in 45min - JBCN2-16 versionSchalk Cronjé
 
State of GeoServer 2.12
State of GeoServer 2.12State of GeoServer 2.12
State of GeoServer 2.12GeoSolutions
 
Java and OpenJDK: disecting the ecosystem
Java and OpenJDK: disecting the ecosystemJava and OpenJDK: disecting the ecosystem
Java and OpenJDK: disecting the ecosystemRafael Winterhalter
 
LocationTech Meetup Hamburg 2014 - GeoGig
LocationTech Meetup Hamburg 2014 - GeoGigLocationTech Meetup Hamburg 2014 - GeoGig
LocationTech Meetup Hamburg 2014 - GeoGigFrank Gasdorf
 

Similar to Top Tips for Migrating to Java 9 (20)

State of GeoServer 2.10
State of GeoServer 2.10State of GeoServer 2.10
State of GeoServer 2.10
 
Fosdem 2011 - A Common Graph Database Access Layer for .Net and Mono
Fosdem 2011 - A Common Graph Database Access Layer for .Net and MonoFosdem 2011 - A Common Graph Database Access Layer for .Net and Mono
Fosdem 2011 - A Common Graph Database Access Layer for .Net and Mono
 
JavaOne報告会 Java SE/JavaFX 編 - JJUG CCC 2010 Fall
JavaOne報告会 Java SE/JavaFX 編 - JJUG CCC 2010 FallJavaOne報告会 Java SE/JavaFX 編 - JJUG CCC 2010 Fall
JavaOne報告会 Java SE/JavaFX 編 - JJUG CCC 2010 Fall
 
How can your applications benefit from Java 9?
How can your applications benefit from Java 9?How can your applications benefit from Java 9?
How can your applications benefit from Java 9?
 
LocationTech Projects
LocationTech ProjectsLocationTech Projects
LocationTech Projects
 
XML-Free Programming : Java Server and Client Development without &lt;>
XML-Free Programming : Java Server and Client Development without &lt;>XML-Free Programming : Java Server and Client Development without &lt;>
XML-Free Programming : Java Server and Client Development without &lt;>
 
React on es6+
React on es6+React on es6+
React on es6+
 
How can your applications benefit from Java 9?
How can your applications benefit from Java 9?How can your applications benefit from Java 9?
How can your applications benefit from Java 9?
 
JavaCro'14 - Scala and Java EE 7 Development Experiences – Peter Pilgrim
JavaCro'14 - Scala and Java EE 7 Development Experiences – Peter PilgrimJavaCro'14 - Scala and Java EE 7 Development Experiences – Peter Pilgrim
JavaCro'14 - Scala and Java EE 7 Development Experiences – Peter Pilgrim
 
JavaCro 2014 Scala and Java EE 7 Development Experiences
JavaCro 2014 Scala and Java EE 7 Development ExperiencesJavaCro 2014 Scala and Java EE 7 Development Experiences
JavaCro 2014 Scala and Java EE 7 Development Experiences
 
DocuOps & Asciidoctor in a JVM World
DocuOps & Asciidoctor in a JVM WorldDocuOps & Asciidoctor in a JVM World
DocuOps & Asciidoctor in a JVM World
 
The dark side of Akka and the remedy - bp.scala meetup
The dark side of Akka and the remedy - bp.scala meetupThe dark side of Akka and the remedy - bp.scala meetup
The dark side of Akka and the remedy - bp.scala meetup
 
Simple Build Tool Introduction
Simple Build Tool IntroductionSimple Build Tool Introduction
Simple Build Tool Introduction
 
State of GeoServer - FOSS4G 2016
State of GeoServer - FOSS4G 2016State of GeoServer - FOSS4G 2016
State of GeoServer - FOSS4G 2016
 
Gradle in 45min - JBCN2-16 version
Gradle in 45min - JBCN2-16 versionGradle in 45min - JBCN2-16 version
Gradle in 45min - JBCN2-16 version
 
Play framework
Play frameworkPlay framework
Play framework
 
Hadoop gets Groovy
Hadoop gets GroovyHadoop gets Groovy
Hadoop gets Groovy
 
State of GeoServer 2.12
State of GeoServer 2.12State of GeoServer 2.12
State of GeoServer 2.12
 
Java and OpenJDK: disecting the ecosystem
Java and OpenJDK: disecting the ecosystemJava and OpenJDK: disecting the ecosystem
Java and OpenJDK: disecting the ecosystem
 
LocationTech Meetup Hamburg 2014 - GeoGig
LocationTech Meetup Hamburg 2014 - GeoGigLocationTech Meetup Hamburg 2014 - GeoGig
LocationTech Meetup Hamburg 2014 - GeoGig
 

Recently uploaded

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
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
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
 
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
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
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
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
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.
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 

Recently uploaded (20)

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...
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
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...
 
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
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
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
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
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
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 

Top Tips for Migrating to Java 9

  • 1. So, you wanna migrate to Java9? by Tomek Adamczewski 13/11/2017
  • 3. Cool features of Java 9 • Project Jigsaw • JShell • Enhanced Collections framework • Enhanced @Deprecated • Project Coin improvements • Support for cgroup limits (think: docker) • G1GC improvements • Changes to JDK Release Model 3 Confidential/Restricted/Public Presentationorparttitle 13/11/2017
  • 4. “Think trains, not limousines” 4 Confidential/Restricted/Public Presentationorparttitle 13/11/2017
  • 5. 5 Confidential/Restricted/Public Presentationorparttitle 13/11/2017 Definition of Done • Code compiles • New features merged to the master branch • All tests pass • The task is documented and closed
  • 6. 1 6 Code Compiles jig·saw [jig-saw] n. a complicated problem consisting of many different parts Confidential/Restricted/Public Presentationorparttitle 13/11/2017
  • 7. There are no silver bullets A lot of libraries or plugins are not compatible with Java 9 yet 7 Confidential/Restricted/Public Presentationorparttitle 13/11/2017
  • 8. Useful tools $ jdeps --jdk-internals -R --class-path ‘lib/*’ guava-HEAD-jre-SNAPSHOT.jar split package: javax.annotation [jrt:/java.xml.ws.annotation, lib/jsr305-1.3.9.jar] guava-HEAD-jre-SNAPSHOT.jar -> jdk.unsupported com.google.common.cache.Striped64 -> sun.misc.Unsafe JDK internal API (jdk.unsupported) com.google.common.cache.Striped64$1 -> sun.misc.Unsafe JDK internal API (jdk.unsupported) (…) JDK Internal API Suggested Replacement ---------------- --------------------- sun.misc.Unsafe See http://openjdk.java.net/jeps/260 8 Confidential/Restricted/Public Presentationorparttitle 13/11/2017
  • 9. …and hacks <artifactId>maven-compiler-plugin</artifactId> <version>3.7.0</version> <configuration> - <source>1.8</source> - <target>1.8</target> + <source>9</source> + <target>9</target> + <compilerArgs> + <arg>--add-exports</arg> + <arg>java.base/sun.security.jca=ALL-UNNAMED</arg> + </compilerArgs> </configuration> 9 Confidential/Restricted/Public Presentationorparttitle 13/11/2017
  • 10. …and hacks java ① --add-opens java.base/java.lang=ALL-UNNAMED ② --add-modules java.xml.ws.annotation ③ --patch-module java.xml.ws.annotation=jsr305-3.0.2.jar --class-path $dependencies -jar $appjar 10 Confidential/Restricted/Public Presentationorparttitle 13/11/2017
  • 12. JEP 302: Lambda Leftovers Treatment of underscores In many languages, it is common to use an underscore (_) to denote an unnamed lambda parameter (and similarly for method and exception parameters): (…) Phase 2 came in Java 9, when this warning became an error. 12 Confidential/Restricted/Public Presentationorparttitle 13/11/2017 BiFunction<Integer, String, String> biss = (i, _) -> String.valueOf(i);
  • 13. Sonar to the rescue!™ 13 Confidential/Restricted/Public Presentationorparttitle 13/11/2017
  • 14. Yet another tool to cope with? 14 Confidential/Restricted/Public Presentationorparttitle 13/11/2017
  • 16. 3 16 New feature merged to the master branch Things might fail or they might not fail Confidential/Restricted/Public Presentationorparttitle 13/11/2017
  • 17. Enhanced Collections framework static <K,V> Map<K,V> of() static <K,V> Map<K,V> of(K k1, V v1) static <K,V> Map<K,V> of(K k1, V v1, K k2, V v2) static <K,V> Map<K,V> of(K k1, V v1, K k2, V v2, K k3, V v3) static <K,V> Map<K,V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7, K k8, V v8, K k9, V v9, K k10, V v10) static <K,V> Map<K,V> ofEntries(Map.Entry<? extends K,? extends V>... entries) 17 Confidential/Restricted/Public Presentationorparttitle 13/11/2017 Map<String, Integer> fooBar = Map.ofEntries( entry("foo", 1), entry("bar", 2), // (...) entry("baz", 42));
  • 18. We’ve all done it before, didn’t we? @SafeVarargs public static <K, V> Map<K, V> map(Entry<K, ? extends V>... entries) { return stream(entries) .filter(Objects::nonNull) .collect(toMap(Entry::getKey, Entry::getValue)); } 18 Confidential/Restricted/Public Presentationorparttitle 13/11/2017
  • 19. private static final Map<String, ErrorReason> ERROR_REASON_MAPPER = map( entry("1001", Format_Incorrect), entry("1002", Format_Expiry_Date_Incorrect), // 95 more entries entry(”6027", Entity_Already_Active)); 19 Case studyConfidential/Restricted/Public Presentationorparttitle 13/11/2017 ---------------------------------- BUILD SUCCESS ---------------------------------- Total time: 01:08 min (Wall Clock)
  • 20. 20 Case studyConfidential/Restricted/Public Presentationorparttitle 13/11/2017 private static final Map<String, ErrorReason> ERROR_REASON_MAPPER = MapUtils.<String, ErrorReason>map( //explicit generics improve compile time by ~50s entry("1001", Format_Incorrect), entry("1002", Format_Expiry_Date_Incorrect), // 95 more entries entry(”6027", Entity_Already_Active)); ---------------------------------- BUILD SUCCESS ---------------------------------- Total time: 10.556 s (Wall Clock)
  • 21. Jenkins build-timeout plugin 21 Confidential/Restricted/Public Presentationorparttitle 13/11/2017 Possible strategies • Absolute • Deadline • Elastic • Likely stuck • No Activity Possible actions • Abort • Fail • Abort and restart • Write build description
  • 22. 4 22 All tests pass Things might fail… but they also might not fail Confidential/Restricted/Public Presentationorparttitle 13/11/2017
  • 23. OptUtils /** @return ofNullable(t).map(provider).orElseGet(supplier) */ public static <T, R> R optGet( T t, Function<T, R> provider, Supplier<R> supplier) { return ofNullable(t).map(provider).orElseGet(supplier); } 23 Confidential/Restricted/Public Presentationorparttitle 13/11/2017
  • 24. You can “unit” test your performance @Test public void testPerf() throws Exception { Result result = benchmark(4, 1000, (thread, pass) -> singlePass(thread, pass)); LOG.info(Table.print(result)); assertExecTimes(result); } 24 Confidential/Restricted/Public Presentationorparttitle 13/11/2017
  • 25. Ugly? But it’s up to 10x faster… /** @return ofNullable(t).map(provider).orElseGet(supplier) */ public static <T, R> R optGet( T t, Function<T, R> provider, Supplier<R> supplier) { return t == null ? supplier.get() : optGet(provider.apply(t), supplier); } /** @return ofNullable(t).orElseGet(supplier) */ public static <T> T optGet(T t, Supplier<T> supplier) { return t == null ? supplier.get() : t; } 25 Confidential/Restricted/Public Presentationorparttitle 13/11/2017
  • 26. 5 26 The task is documented and closed In case you just woke up… Confidential/Restricted/Public Presentationorparttitle 13/11/2017
  • 27. Brace yourself Java WILL be updated every 6 months. Make sure you’re armed and ready 27 Confidential/Restricted/Public Presentationorparttitle 13/11/2017