What’s new with Java >=9?
Don’t be afraid of Jigsaw! A few words about me
Lille
Rennes Blois Tours Lyon
blog.worldline.tech
2 | JF James | © Worldline | Touraine Tech Agenda
3 | JF James | © Worldline | Touraine Tech A brief history of Java JDK distribution size (compressed MB) 8
7
6
1.4 5.0
1.3 1.2
1.1 1.0 Release date (y)
4 | JF James | © Worldline | Touraine Tech Refresher on Java SE 8 Released on 18 March 2014 New Date Time API
Streams Collectors Lambda expression
Functional & asynchronous programming
Method reference Optional CompletableFuture
5 | JF James | © Worldline | Touraine Tech Ready for Java 9? More than 80 changes
Multi-release Jar file Reactive Streams API
6 | JF James | © Worldline | Touraine Tech Expected benefits of the JDK modularity
Maintenance Innovation
Security Scalability
Performance Robustness
7 | JF James | © Worldline | Touraine Tech The long story of Java Modularity
Started in 2005 (JSR 277), released in September 2017 (JSR 376)
8 | JF James | © Worldline | Touraine Tech Discovering JPMS
Java native modular system Makes modules explicit Modularize the JDK itself Open to Java Applications
Strong encapsulation by exporting or opening packages
Explicit and reliable dependencies
9 | JF James | © Worldline | Touraine Tech The new look of the JDK
10 | JF James | © Worldline | Touraine Tech How efficient is the JDK modularity? 35 000
30 000
25 000
20 000 With modularity 15 000
10 000
5 000
0
11 | JF James | © Worldline | Touraine Tech Opening packages
import java.fx.Application; module easytext.gui { public class MyApp extends Application { opens easytext.gui to javafx.graphics; public static void main(String … args) { requires javax.graphics; Application.launch(args); } } }
12 | JF James | © Worldline | Touraine Tech Modular Java Services
Provider:
module easytext.analysis.coleman { provides easytext.analysis.api.Analyser with easytext.analysis.coleman.ColemanAnalyser; }
Consumer:
module easytext.analysis.client { uses easytext.analysis.api.Analyser; } … ServiceLoader.load(Analyzer.class);
13 | JF James | © Worldline | Touraine Tech Welcome to the modulepath!
Classpath-based Modulepath-based
Under your control Legacy App Modular App
Out of your Legacy Frameworks & Modular Frameworks & control libraries libraries
Already modular Modular JDK
14 | JF James | © Worldline | Touraine Tech On the road to application modularity
classpath modulepath
module file.jar file.jar info file.jar
Legacy jar Automatic module Explicit module
Part of the unnamed module Module name derived (2) or defined (3) Explicit access to other modules Everything exported & opened Everything exported & opened Classpath unreadable Can access everything (1) Can access everything (1) --illegal-access allowed –add-opens & add-exports allowed
(1) From the classpath&modules (2) From the jar file name (3) Using Automatic-Module-Name (MANIFEST.MF)
15 | JF James | © Worldline | Touraine Tech Naming modules
Use Automatic-Module-Name to define a stable name for library modules No version number in module name
16 | JF James | © Worldline | Touraine Tech Just enough runtime with JLink Creating custom "Java Images" for your applications
17 | JF James | © Worldline | Touraine Tech Oracle new strategy
• The Reference Implementation • 100% OpenJDK based • Including previous commercial features • Commercial offering • Pure Open Source • Long Term Support • GPL V2 + Class Path extension • Free of use and distribution • Time-driven release model
18 | JF James | © Worldline | Touraine Tech Make Java innovative again!
2017 Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec OpenJDK 9
2018 Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec Feature OpenJDK 10.0 11.0 Update OpenJDK 10.0.1 10.0.2 11.0.1 LTS Oracle JDK 11.0 LTS
2019 Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec Feature OpenJDK Eof 12.0 13.0 Update OpenJDK 11.0.2JDK8 12.0.1 12.0.2 13.0.1 LTS Oracle JDK
2020 Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec Feature OpenJDK 14.0 15.0 Eof Update OpenJDK 13.0.2 14.0.1 14.0.2 JDK815.0.1 LTS Oracle JDK
19 | JF James | © Worldline | Touraine Tech Challenges ahead of us
• Should I run my App on Java 9? – Better performance expected (to be tested) 2018 – Some adaptations needed: command lines, code (minor impact) – Warning: G1 optimal for heap size >=4GB
2018-2019 • Should I use feature-releases or LTS? – Eof Oracle JDK 9 support in Jan. 2019 – Feature-releases free of charge, more suited for short lifecycle App with Continuous Deployment in place – Conversely LTS suited for long lifecycle App
20 | JF James | © Worldline | Touraine Tech Challenges ahead of us
• Should I modularize my App? 2018-2019 – Probably no for most legacy Applications – To be assessed for existing Applications with long-term perspective – Yes for new applications – Dev and build tools will help
• Should I deliver a JLink-based custom runtime image in production? – Probably yes to make the most of modular Applications – JLink can be part the build chain 2019 – Responsibility of the Runtime delivery moved to Dev – Good fit with containerization
21 | JF James | © Worldline | Touraine Tech
Challenges ahead of us
2018-2019-2020 …
• Last but not least … Training … Experiencing … Knowledge sharing – Java 9 is not just about fancy Dev features – It is a game changer! – Mastering modularity and its subtleties will take time – It puts back good practices on the stage at the price of an additional complexity – And don’t forget the other 79 changes ;-)
22 | JF James | © Worldline | Touraine Tech
Thanks!
23
Appendixes
24 Main references
• Jigsaw Quickstart: http://openjdk.java.net/projects/jigsaw/quick-start
• Oracle JDK9 Migration Guide: https://docs.oracle.com/javase/9/migrate/
• Alex Buckley talk: https://www.youtube.com/watch?v=rfOjch4p0Po
25 | JF James | © Worldline | Touraine Tech Other interesting references • http://in.relation.to/2017/04/11/accessing-private-state-of-java-9-modules/ • http://in.relation.to/2017/02/13/building-multi-release-jars-with-maven/ • https://www.youtube.com/watch?v=Txsl-K83ygI • https://cwiki.apache.org/confluence/display/MAVEN/Java+9+-+Jigsaw • https://blog.frankel.ch/migrating-to-java-9/1/#gsc.tab=0 • https://blog.frankel.ch/migrating-to-java-9/2/#gsc.tab=0 • https://blog.idrsolutions.com/2017/06/java-9-articles-series-index/ • https://blog.senacor.com/unit-testing-with-java-9-jigsaw-and-junit/ • https://stackoverflow.com/questions/46613214/java-9-maven-junit-does-test-code-need-module-info- java-of-its-own-and-wher • https://issues.apache.org/jira/browse/SUREFIRE-1420 • https://blog.codefx.org/ • https://speakerdeck.com/forax/tu-modules-2# • https://access.redhat.com/articles/1299013 • http://www.oracle.com/technetwork/java/eol-135779.html
26 | JF James | © Worldline | Touraine Tech
Java version history
Version Code Name Release date Delta (y) Size (MB) Size Increase JDK 1.0 Oak janv-96 4 JDK 1.1 févr-97 1,0 9 125% J2SE 1.2 Playground déc-98 1,8 20 122% J2SE 1.3 Kestrel mai-00 1,4 24 20% J2SE 1.4 Merlin févr-02 1,7 38 58% J2SE 5.0 Tiger sept-04 2,6 40 5% Java SE 6 Mustang déc-06 2,2 65 63% Java SE 7 Dolphin juil-11 4,5 130 100% Java SE 8 Spider mars-14 2,7 151 16% Java SE 9 sept-17 3,5 304 101%
27 | JF James | © Worldline | Touraine Tech Thanks For more information please contact: [email protected]
Atos, the Atos logo, Atos Consulting, Atos Worldgrid, Worldline, BlueKiwi, Bull, Canopy the Open Cloud Company, Yunano, Zero Email, Zero Email Certified and The Zero Email Company are registered trademarks of the Atos group. May 2015. © 2015 Atos. Confidential information owned by Atos, to be used by the recipient only. This document, or any part of it, may not be reproduced, copied, circulated and/or distributed nor quoted without prior written approval from Atos.
© Worldline