SlideShare ist ein Scribd-Unternehmen logo
1 von 56
© CGI Group Inc. PUBLIC
Java 9 and the impact on
Maven Projects
Robert Scholte (@rfscholte )
Chairman Apache Maven
“The success of Java 9 depends on
the adoption by IDEs and buildtools
like Maven”
Early Access releases
• Jigsaw
– Since September 2015
– https://jdk9.java.net/jigsaw/
– ZIP
• Java9
– Since April 2014
– https://jdk9.java.net/download/
– Executable
Challenge/Strategy Maven and Java9
• Support Maven 3.0 and above
• Only upgrades of plugins
Standard Java upgrade
• Set Java Runtime for Maven
– JAVA_HOME=/path/to/jdk-9
• Verify source/target of maven-compiler-
plugin
– >= 6 (minimum jdk-9), okay
– < 6, must fork to preferred JDK
Maven JRE <> maven-compiler-plugin JDK
JEP 260: Encapsulate Most Internal APIs
Summary
Make most of the JDK's internal APIs
inaccessible by default but leave a few
critical, widely-used internal APIs accessible,
until supported replacements exist for all or
most of their functionality.
Results so far
• First java9-ea releases: close to no issues
• First jigsaw-ea release: ~99% of the Java
Maven projects failed to compile.
• Cause: JavacToolProvider + (System)Classloader
• Fixed and released within 72h!
• zero lines of code changed in Maven core
codebase to run on Java9
~10% of JEPs related to Maven
• 220: Modular Run-Time Images *
• 223: New Version-String Scheme
• 226: UTF-8 Property Files
• 238: Multi-Release JAR Files
• 247: Compile for Older Platform Versions
• 261: Module System *
• 275: Modular Java Application Packaging (?)
• 282: jlink: The Java Linker *
* Part of JSR 376: Java Platform Module System (Project jigsaw)
Agenda
• 220: Modular Run-Time Images *
• 223: New Version-String Scheme
• 226: UTF-8 Property Files
• 238: Multi-Release JAR Files
• 247: Compile for Older Platform Versions
• 261: Module System *
• 275: Modular Java Application Packaging (?)
• 282: jlink: The Java Linker *
* Part of JSR 376: Java Platform Module System (Project jigsaw)
JEP 226: UTF-8 Property Files
Summary
Define a means for applications to specify
property files encoded in UTF-8, and extend
the ResourceBundle API to load them.
JEP 223: New Version-String Scheme
(project Verona)
Summary
Revise the JDK's version-string scheme so
that it is easier to distinguish major, minor,
and security-update releases.
Major (GA) Example
System property Existing Proposed
java.version 1.9.0 9
java.runtime.version 1.9.0-b100 9+100
java.vm.version 1.9.0-b100 9+100
java.specification.version 1.9 9
java.vm.specification.version 1.9 9
version.split(“.”)[1]
Caused by: java.lang.ArrayIndexOutOfBoundsException: 1
at org.codehaus.plexus.archiver.zip.AbstractZipArchiver….
maven-archiver-3.0.1
- maven-jar-plugin-3.0.0
- maven-war-plugin-3.0.0
- maven-ear-plugin-xxx
maven-javadoc-plugin-2.10.4
…
JEP 247: Compile for Older Platform Versions
Summary
Enhance javac so that it can compile Java
programs to run on selected older versions
of the platform.
The problem
Leaking classes of the JDK
The official required javac arguments
-source N
-target N
-bootclasspath <bootclasspath-from-N>
Available Maven Solutions (1)
Always compile with the matching JDK
version
- Configure maven-toolchain-plugin
- Configure toolchains.xml
- ${user.home}/.m2/toolchains.xml
- ${maven.home}/conf/toolchains.xml (since 3.3.1)
Available Maven Solutions (2)
Verify code with jre signatures
- Configure animal-sniffer-maven-plugin
- Signature for N
- Execution block with ‘check’ goal
Solution
We defined a new command-line option,
-release, which automatically configures the
compiler to produce class files that will link
against an implementation of the given
platform version. For the platforms
predefined in javac,
-release N is equivalent to
-source N -target N -bootclasspath
<bootclasspath-from-N>.
maven-compiler-plugin 3.6
• <release>N</release>
• If source/target AND release are specified,
use release.
Forward compatibility
if ( javaVersion >= 1.8 ) {
// calculation based on Date-Time API (preferred)
}
else {
// calculation based on Date
}
source/target: 1.7
JDK: 1.8
JDK: 1.7 with reflection
JEP 238: Multi-Release JAR Files
Summary
Extend the JAR file format to allow multiple,
Java-release-specific versions of class files
to coexist in a single archive.
JAR structure
jar root
- A.class
- B.class
- C.class
- D.class
- META-INF
- versions
- 8
- A.class
- B.class
- 9
- A.class
1 to 1 translation
project root
src/main/java
- A.java
- B.java
- C.java
- D.java
src/main/java8
- A.java
- B.java
src/main/java9
- A.java
Will work with Maven execution-blocks, not with (all) IDEs
IDE friendly POC
multimodule root
multirelease-base/src/main/java
- A.java
- B.java
- C.java
- D.java
multirelease-eight/src/main/java
- A.java
- B.java
multirelease-nine/src/main/java
- A.java
multirelease/src/assembly/mvjar.xml
https://github.com/hboutemy/maven-jep238
Improvements (in progress)
• Introduce new packaging (no
install/deploy)
• Merge dependencies in JDK profiles
• Remove assembly descriptor
JEP 220: Modular Run-Time Images
Summary
Restructure the JDK and JRE run-time images
to accommodate modules and to improve
performance, security, and maintainability.
Define a new URI scheme for naming the
modules, classes, and resources stored in a
run-time image without revealing the internal
structure or format of the image. Revise
existing specifications as required to
accommodate these changes.
Removal of tools.jar
• Most Apache maven-plugins already have
a lot of fallback scenarios for a long time.
• Projects that might suffer
– custom doclettags
Tools.jar profile
<profile>
<id>default-tools.jar</id>
<activation>
<jdk>(,9)</jdk> <!-- System.getProperty( “java.version” ) -->
</activation>
<dependencies>
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.4.2</version>
<scope>system</scope>
<systemPath>${java.home}/../lib/tools.jar</systemPath>
</dependency>
</dependencies>
</profile>
JEP 261: Module System
Summary
Implement the Java Platform Module
System, as specified by JSR 376, together
with related JDK-specific changes and
enhancements.
In a nutshell
• module-info.java
– Specify exposed packages
– Specify required modules (buildtime +
runtime)
– Specify usage and implementation of SPIs
Module Declarations Example
module M.N {
requires A.B;
requires public C.D;
requires static E.F;
requires public static G.H;
exports P.Q;
exports R.S to T1.U1, T2.U2;
exports dynamic PP.QQ;
exports dynamic RR.SS to T1.U1, T2.U2;
uses V.W;
provides X.Y with Z1.Z2;
provides X.Y with Z3.Z4;
}
Requires Modifier ‘public’
comparable with transitive
Maven best practice: don’t trust transitive
dependencies; specify dependency for every
used class
Requires Modifier ‘static’
comparable with dependency.optional
Difference provided versus optional
– Buildtime: no difference
– Runtime:
• provided must be available (servlet-api)
• optional might be available (spring-boot deps)
Common usecases
maven-compiler-plugin
• :compile, switch to modulepath when
compiling module-info.java
• :test-compile, switch to modulepath +
classpath when target/classes/module-
info.class exists
Building Maven with Maven
Discover moduleName
• Documentation
• Central/Repository Managers?
Archiva/Artifactory/Nexus
• maven-dependency-plugin:list
For library/framework/maven-plugin/… builders
• The lower the supported Java version, the
more projects can use it
• The lower the supported Java version, the
less Java features can be used.
Can we add module-info? Yes!
Backwards compatible libraries
• module-info (-release 9)
• (other) java sources (source/target < 9)
• Multi Release JAR?
• 2 Execution blocks?
• Maven-compiler-plugin magic? Vote NO
Dependencies and classpath
• Classpath order:
– all direct dependencies
– all first level indirect dependencies
– all second level indirect dependencies
– …
• Locating a class: iterate over classpath (in
same order); first match wins
Dependencies and modulepath
• Modulepath: packages are mapped to a
module
– Duplicate packages will result in an Exception
• Locating a class: find module based on
package; get class from module
GOTCHA: Dependency Excludes
javac --limit-modules <module>(,<module>)*
JAR required to discover moduleName
Maven excludes dependencies upfront, no
need to download pom/jar.
No solution yet; workaround: <arguments/>
Are we ready?
Java Platform Module System: Issue Summary
http://openjdk.java.net/projects/jigsaw/spec/issues/
maven-shade-plugin
This plugin provides the capability to package the artifact in
an uber-jar, including its dependencies and to shade - i.e.
rename the packages of some of the dependencies.
• Merging module-info files will break
encapsulation
• Relocation
Animal-sniffer signatures
• Per module?
• Still required now that we have –release?
Is my project Java9-ready?
• Is it using internal classes?
– maven-jdeps-plugin-3.0.0
• Does it have duplicate
– extra-enforcer-rule > banDuplicateClasses
• Does it require certain Java9 features
– Upgrade the matching plugins
The Apache Maven project tasklist
• Most features should work with Maven 3.0
• Some require Maven 3.3.1 due to
improved toolchains support
• Large number of new features already
developed in plugins, though not always
released.
• New recipes “The Maven Way™”
Developer awareness
• Module-info.java triggers modulepath
• test-compile uses both modulepath
(main/java) and classpath (test/java)
• When Java9/Jigsaw fails:
– Usage internal APIs
– Duplicate (exported) packages
Maven Wiki
https://cwiki.apache.org/confluence/display/
MAVEN/Java+9+-+Jigsaw
Thank you
Give it a try!
Send feedback, issues & wishes

Weitere ähnliche Inhalte

Was ist angesagt?

Polygot Java EE on the GraalVM
Polygot Java EE on the GraalVMPolygot Java EE on the GraalVM
Polygot Java EE on the GraalVMRyan Cuprak
 
OpenJDK-Zulu talk at JEEConf'14
OpenJDK-Zulu talk at JEEConf'14OpenJDK-Zulu talk at JEEConf'14
OpenJDK-Zulu talk at JEEConf'14Ivan Krylov
 
Workflow automation for Front-end web applications
Workflow automation for Front-end web applicationsWorkflow automation for Front-end web applications
Workflow automation for Front-end web applicationsMayank Patel
 
Exploring Java Heap Dumps (Oracle Code One 2018)
Exploring Java Heap Dumps (Oracle Code One 2018)Exploring Java Heap Dumps (Oracle Code One 2018)
Exploring Java Heap Dumps (Oracle Code One 2018)Ryan Cuprak
 
JDK 9: Big Changes To Make Java Smaller
JDK 9: Big Changes To Make Java SmallerJDK 9: Big Changes To Make Java Smaller
JDK 9: Big Changes To Make Java SmallerSimon Ritter
 
Modularity of the Java Platform (OSGi, Jigsaw and Penrose)
Modularity of the Java Platform (OSGi, Jigsaw and Penrose)Modularity of the Java Platform (OSGi, Jigsaw and Penrose)
Modularity of the Java Platform (OSGi, Jigsaw and Penrose)Martin Toshev
 
Java 9 Module System Introduction
Java 9 Module System IntroductionJava 9 Module System Introduction
Java 9 Module System IntroductionDan Stine
 
Modularization With Project Jigsaw in JDK 9
Modularization With Project Jigsaw in JDK 9Modularization With Project Jigsaw in JDK 9
Modularization With Project Jigsaw in JDK 9Simon Ritter
 
Faster java ee builds with gradle [con4921]
Faster java ee builds with gradle [con4921]Faster java ee builds with gradle [con4921]
Faster java ee builds with gradle [con4921]Ryan Cuprak
 
JDK 9: Mission Accomplished. What Next For Java?
JDK 9: Mission Accomplished. What Next For Java?JDK 9: Mission Accomplished. What Next For Java?
JDK 9: Mission Accomplished. What Next For Java?Simon Ritter
 
Java EE 8 Update
Java EE 8 UpdateJava EE 8 Update
Java EE 8 UpdateRyan Cuprak
 
Migrating to java 9 modules
Migrating to java 9 modulesMigrating to java 9 modules
Migrating to java 9 modulesPaul Bakker
 

Was ist angesagt? (20)

Java 9 and Beyond
Java 9 and BeyondJava 9 and Beyond
Java 9 and Beyond
 
JDK-9: Modules and Java Linker
JDK-9: Modules and Java LinkerJDK-9: Modules and Java Linker
JDK-9: Modules and Java Linker
 
Polygot Java EE on the GraalVM
Polygot Java EE on the GraalVMPolygot Java EE on the GraalVM
Polygot Java EE on the GraalVM
 
Migrating to Java 9 Modules
Migrating to Java 9 ModulesMigrating to Java 9 Modules
Migrating to Java 9 Modules
 
OpenJDK-Zulu talk at JEEConf'14
OpenJDK-Zulu talk at JEEConf'14OpenJDK-Zulu talk at JEEConf'14
OpenJDK-Zulu talk at JEEConf'14
 
Java 9 Modularity in Action
Java 9 Modularity in ActionJava 9 Modularity in Action
Java 9 Modularity in Action
 
Workflow automation for Front-end web applications
Workflow automation for Front-end web applicationsWorkflow automation for Front-end web applications
Workflow automation for Front-end web applications
 
Exploring Java Heap Dumps (Oracle Code One 2018)
Exploring Java Heap Dumps (Oracle Code One 2018)Exploring Java Heap Dumps (Oracle Code One 2018)
Exploring Java Heap Dumps (Oracle Code One 2018)
 
JDK 9: Big Changes To Make Java Smaller
JDK 9: Big Changes To Make Java SmallerJDK 9: Big Changes To Make Java Smaller
JDK 9: Big Changes To Make Java Smaller
 
Modularity of the Java Platform (OSGi, Jigsaw and Penrose)
Modularity of the Java Platform (OSGi, Jigsaw and Penrose)Modularity of the Java Platform (OSGi, Jigsaw and Penrose)
Modularity of the Java Platform (OSGi, Jigsaw and Penrose)
 
Java modularity: life after Java 9
Java modularity: life after Java 9Java modularity: life after Java 9
Java modularity: life after Java 9
 
Java 9 Module System Introduction
Java 9 Module System IntroductionJava 9 Module System Introduction
Java 9 Module System Introduction
 
Java modules using project jigsaw@jdk 9
Java modules using project jigsaw@jdk 9Java modules using project jigsaw@jdk 9
Java modules using project jigsaw@jdk 9
 
Apache DeltaSpike the CDI toolbox
Apache DeltaSpike the CDI toolboxApache DeltaSpike the CDI toolbox
Apache DeltaSpike the CDI toolbox
 
Modularization With Project Jigsaw in JDK 9
Modularization With Project Jigsaw in JDK 9Modularization With Project Jigsaw in JDK 9
Modularization With Project Jigsaw in JDK 9
 
Faster java ee builds with gradle [con4921]
Faster java ee builds with gradle [con4921]Faster java ee builds with gradle [con4921]
Faster java ee builds with gradle [con4921]
 
Java 9 and Project Jigsaw
Java 9 and Project JigsawJava 9 and Project Jigsaw
Java 9 and Project Jigsaw
 
JDK 9: Mission Accomplished. What Next For Java?
JDK 9: Mission Accomplished. What Next For Java?JDK 9: Mission Accomplished. What Next For Java?
JDK 9: Mission Accomplished. What Next For Java?
 
Java EE 8 Update
Java EE 8 UpdateJava EE 8 Update
Java EE 8 Update
 
Migrating to java 9 modules
Migrating to java 9 modulesMigrating to java 9 modules
Migrating to java 9 modules
 

Ähnlich wie Java 9 and the impact on Maven Projects (JavaOne 2016)

Preparing for java 9 modules upload
Preparing for java 9 modules uploadPreparing for java 9 modules upload
Preparing for java 9 modules uploadRyan Cuprak
 
Apache Maven supports all Java (JokerConf 2018)
Apache Maven supports all Java (JokerConf 2018)Apache Maven supports all Java (JokerConf 2018)
Apache Maven supports all Java (JokerConf 2018)Robert Scholte
 
Apache maven and its impact on java 9 (Java One 2017)
Apache maven and its impact on java 9 (Java One 2017)Apache maven and its impact on java 9 (Java One 2017)
Apache maven and its impact on java 9 (Java One 2017)Robert Scholte
 
Java 9 / Jigsaw - AJUG/VJUG session
Java 9 / Jigsaw - AJUG/VJUG  sessionJava 9 / Jigsaw - AJUG/VJUG  session
Java 9 / Jigsaw - AJUG/VJUG sessionMani Sarkar
 
Apache Maven supports ALL Java (Javaland 2019)
Apache Maven supports ALL Java (Javaland 2019)Apache Maven supports ALL Java (Javaland 2019)
Apache Maven supports ALL Java (Javaland 2019)Robert Scholte
 
Modern Java Workshop
Modern Java WorkshopModern Java Workshop
Modern Java WorkshopSimon Ritter
 
Java in a world of containers
Java in a world of containersJava in a world of containers
Java in a world of containersDocker, Inc.
 
Java in a World of Containers - DockerCon 2018
Java in a World of Containers - DockerCon 2018Java in a World of Containers - DockerCon 2018
Java in a World of Containers - DockerCon 2018Arun Gupta
 
Haj 4344-java se 9 and the application server-1
Haj 4344-java se 9 and the application server-1Haj 4344-java se 9 and the application server-1
Haj 4344-java se 9 and the application server-1Kevin Sutter
 
Why should i switch to Java SE 7
Why should i switch to Java SE 7Why should i switch to Java SE 7
Why should i switch to Java SE 7Vinay H G
 
Jdc 2010 - Maven, Intelligent Projects
Jdc 2010 - Maven, Intelligent ProjectsJdc 2010 - Maven, Intelligent Projects
Jdc 2010 - Maven, Intelligent ProjectsMert Çalışkan
 
JavaOne 2016: Life after Modularity
JavaOne 2016: Life after ModularityJavaOne 2016: Life after Modularity
JavaOne 2016: Life after ModularityDanHeidinga
 
Leaner microservices with Java 10
Leaner microservices with Java 10Leaner microservices with Java 10
Leaner microservices with Java 10Arto Santala
 
Netbeans
NetbeansNetbeans
Netbeansacosdt
 
Modularity of The Java Platform Javaday (http://javaday.org.ua/)
Modularity of The Java Platform Javaday (http://javaday.org.ua/)Modularity of The Java Platform Javaday (http://javaday.org.ua/)
Modularity of The Java Platform Javaday (http://javaday.org.ua/)Martin Toshev
 
Modules all the way down: OSGi and the Java Platform Module System
Modules all the way down: OSGi and the Java Platform Module SystemModules all the way down: OSGi and the Java Platform Module System
Modules all the way down: OSGi and the Java Platform Module SystemTim Ellison
 

Ähnlich wie Java 9 and the impact on Maven Projects (JavaOne 2016) (20)

Preparing for java 9 modules upload
Preparing for java 9 modules uploadPreparing for java 9 modules upload
Preparing for java 9 modules upload
 
Apache Maven supports all Java (JokerConf 2018)
Apache Maven supports all Java (JokerConf 2018)Apache Maven supports all Java (JokerConf 2018)
Apache Maven supports all Java (JokerConf 2018)
 
Apache maven and its impact on java 9 (Java One 2017)
Apache maven and its impact on java 9 (Java One 2017)Apache maven and its impact on java 9 (Java One 2017)
Apache maven and its impact on java 9 (Java One 2017)
 
Java 9 / Jigsaw - AJUG/VJUG session
Java 9 / Jigsaw - AJUG/VJUG  sessionJava 9 / Jigsaw - AJUG/VJUG  session
Java 9 / Jigsaw - AJUG/VJUG session
 
Apache Maven supports ALL Java (Javaland 2019)
Apache Maven supports ALL Java (Javaland 2019)Apache Maven supports ALL Java (Javaland 2019)
Apache Maven supports ALL Java (Javaland 2019)
 
Apache Maven for AT/QC
Apache Maven for AT/QCApache Maven for AT/QC
Apache Maven for AT/QC
 
Modern Java Workshop
Modern Java WorkshopModern Java Workshop
Modern Java Workshop
 
Java in a world of containers
Java in a world of containersJava in a world of containers
Java in a world of containers
 
Java in a World of Containers - DockerCon 2018
Java in a World of Containers - DockerCon 2018Java in a World of Containers - DockerCon 2018
Java in a World of Containers - DockerCon 2018
 
Apache Maven basics
Apache Maven basicsApache Maven basics
Apache Maven basics
 
Haj 4344-java se 9 and the application server-1
Haj 4344-java se 9 and the application server-1Haj 4344-java se 9 and the application server-1
Haj 4344-java se 9 and the application server-1
 
Why should i switch to Java SE 7
Why should i switch to Java SE 7Why should i switch to Java SE 7
Why should i switch to Java SE 7
 
Jdc 2010 - Maven, Intelligent Projects
Jdc 2010 - Maven, Intelligent ProjectsJdc 2010 - Maven, Intelligent Projects
Jdc 2010 - Maven, Intelligent Projects
 
JavaOne 2016: Life after Modularity
JavaOne 2016: Life after ModularityJavaOne 2016: Life after Modularity
JavaOne 2016: Life after Modularity
 
Leaner microservices with Java 10
Leaner microservices with Java 10Leaner microservices with Java 10
Leaner microservices with Java 10
 
Maven Introduction
Maven IntroductionMaven Introduction
Maven Introduction
 
Ja coco ignite
Ja coco igniteJa coco ignite
Ja coco ignite
 
Netbeans
NetbeansNetbeans
Netbeans
 
Modularity of The Java Platform Javaday (http://javaday.org.ua/)
Modularity of The Java Platform Javaday (http://javaday.org.ua/)Modularity of The Java Platform Javaday (http://javaday.org.ua/)
Modularity of The Java Platform Javaday (http://javaday.org.ua/)
 
Modules all the way down: OSGi and the Java Platform Module System
Modules all the way down: OSGi and the Java Platform Module SystemModules all the way down: OSGi and the Java Platform Module System
Modules all the way down: OSGi and the Java Platform Module System
 

Kürzlich hochgeladen

Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 

Kürzlich hochgeladen (20)

Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 

Java 9 and the impact on Maven Projects (JavaOne 2016)

  • 1. © CGI Group Inc. PUBLIC Java 9 and the impact on Maven Projects Robert Scholte (@rfscholte ) Chairman Apache Maven
  • 2. “The success of Java 9 depends on the adoption by IDEs and buildtools like Maven”
  • 3. Early Access releases • Jigsaw – Since September 2015 – https://jdk9.java.net/jigsaw/ – ZIP • Java9 – Since April 2014 – https://jdk9.java.net/download/ – Executable
  • 4. Challenge/Strategy Maven and Java9 • Support Maven 3.0 and above • Only upgrades of plugins
  • 5. Standard Java upgrade • Set Java Runtime for Maven – JAVA_HOME=/path/to/jdk-9 • Verify source/target of maven-compiler- plugin – >= 6 (minimum jdk-9), okay – < 6, must fork to preferred JDK Maven JRE <> maven-compiler-plugin JDK
  • 6. JEP 260: Encapsulate Most Internal APIs Summary Make most of the JDK's internal APIs inaccessible by default but leave a few critical, widely-used internal APIs accessible, until supported replacements exist for all or most of their functionality.
  • 7. Results so far • First java9-ea releases: close to no issues • First jigsaw-ea release: ~99% of the Java Maven projects failed to compile. • Cause: JavacToolProvider + (System)Classloader • Fixed and released within 72h! • zero lines of code changed in Maven core codebase to run on Java9
  • 8. ~10% of JEPs related to Maven • 220: Modular Run-Time Images * • 223: New Version-String Scheme • 226: UTF-8 Property Files • 238: Multi-Release JAR Files • 247: Compile for Older Platform Versions • 261: Module System * • 275: Modular Java Application Packaging (?) • 282: jlink: The Java Linker * * Part of JSR 376: Java Platform Module System (Project jigsaw)
  • 9. Agenda • 220: Modular Run-Time Images * • 223: New Version-String Scheme • 226: UTF-8 Property Files • 238: Multi-Release JAR Files • 247: Compile for Older Platform Versions • 261: Module System * • 275: Modular Java Application Packaging (?) • 282: jlink: The Java Linker * * Part of JSR 376: Java Platform Module System (Project jigsaw)
  • 10. JEP 226: UTF-8 Property Files Summary Define a means for applications to specify property files encoded in UTF-8, and extend the ResourceBundle API to load them.
  • 11.
  • 12. JEP 223: New Version-String Scheme (project Verona) Summary Revise the JDK's version-string scheme so that it is easier to distinguish major, minor, and security-update releases.
  • 13. Major (GA) Example System property Existing Proposed java.version 1.9.0 9 java.runtime.version 1.9.0-b100 9+100 java.vm.version 1.9.0-b100 9+100 java.specification.version 1.9 9 java.vm.specification.version 1.9 9
  • 14. version.split(“.”)[1] Caused by: java.lang.ArrayIndexOutOfBoundsException: 1 at org.codehaus.plexus.archiver.zip.AbstractZipArchiver…. maven-archiver-3.0.1 - maven-jar-plugin-3.0.0 - maven-war-plugin-3.0.0 - maven-ear-plugin-xxx maven-javadoc-plugin-2.10.4 …
  • 15. JEP 247: Compile for Older Platform Versions Summary Enhance javac so that it can compile Java programs to run on selected older versions of the platform.
  • 16. The problem Leaking classes of the JDK The official required javac arguments -source N -target N -bootclasspath <bootclasspath-from-N>
  • 17.
  • 18. Available Maven Solutions (1) Always compile with the matching JDK version - Configure maven-toolchain-plugin - Configure toolchains.xml - ${user.home}/.m2/toolchains.xml - ${maven.home}/conf/toolchains.xml (since 3.3.1)
  • 19. Available Maven Solutions (2) Verify code with jre signatures - Configure animal-sniffer-maven-plugin - Signature for N - Execution block with ‘check’ goal
  • 20. Solution We defined a new command-line option, -release, which automatically configures the compiler to produce class files that will link against an implementation of the given platform version. For the platforms predefined in javac, -release N is equivalent to -source N -target N -bootclasspath <bootclasspath-from-N>.
  • 21. maven-compiler-plugin 3.6 • <release>N</release> • If source/target AND release are specified, use release.
  • 22.
  • 23. Forward compatibility if ( javaVersion >= 1.8 ) { // calculation based on Date-Time API (preferred) } else { // calculation based on Date } source/target: 1.7 JDK: 1.8 JDK: 1.7 with reflection
  • 24. JEP 238: Multi-Release JAR Files Summary Extend the JAR file format to allow multiple, Java-release-specific versions of class files to coexist in a single archive.
  • 25. JAR structure jar root - A.class - B.class - C.class - D.class - META-INF - versions - 8 - A.class - B.class - 9 - A.class
  • 26. 1 to 1 translation project root src/main/java - A.java - B.java - C.java - D.java src/main/java8 - A.java - B.java src/main/java9 - A.java Will work with Maven execution-blocks, not with (all) IDEs
  • 27. IDE friendly POC multimodule root multirelease-base/src/main/java - A.java - B.java - C.java - D.java multirelease-eight/src/main/java - A.java - B.java multirelease-nine/src/main/java - A.java multirelease/src/assembly/mvjar.xml https://github.com/hboutemy/maven-jep238
  • 28.
  • 29. Improvements (in progress) • Introduce new packaging (no install/deploy) • Merge dependencies in JDK profiles • Remove assembly descriptor
  • 30. JEP 220: Modular Run-Time Images Summary Restructure the JDK and JRE run-time images to accommodate modules and to improve performance, security, and maintainability. Define a new URI scheme for naming the modules, classes, and resources stored in a run-time image without revealing the internal structure or format of the image. Revise existing specifications as required to accommodate these changes.
  • 31. Removal of tools.jar • Most Apache maven-plugins already have a lot of fallback scenarios for a long time. • Projects that might suffer – custom doclettags
  • 32. Tools.jar profile <profile> <id>default-tools.jar</id> <activation> <jdk>(,9)</jdk> <!-- System.getProperty( “java.version” ) --> </activation> <dependencies> <dependency> <groupId>com.sun</groupId> <artifactId>tools</artifactId> <version>1.4.2</version> <scope>system</scope> <systemPath>${java.home}/../lib/tools.jar</systemPath> </dependency> </dependencies> </profile>
  • 33. JEP 261: Module System Summary Implement the Java Platform Module System, as specified by JSR 376, together with related JDK-specific changes and enhancements.
  • 34. In a nutshell • module-info.java – Specify exposed packages – Specify required modules (buildtime + runtime) – Specify usage and implementation of SPIs
  • 35. Module Declarations Example module M.N { requires A.B; requires public C.D; requires static E.F; requires public static G.H; exports P.Q; exports R.S to T1.U1, T2.U2; exports dynamic PP.QQ; exports dynamic RR.SS to T1.U1, T2.U2; uses V.W; provides X.Y with Z1.Z2; provides X.Y with Z3.Z4; }
  • 36. Requires Modifier ‘public’ comparable with transitive Maven best practice: don’t trust transitive dependencies; specify dependency for every used class
  • 37. Requires Modifier ‘static’ comparable with dependency.optional Difference provided versus optional – Buildtime: no difference – Runtime: • provided must be available (servlet-api) • optional might be available (spring-boot deps)
  • 39. maven-compiler-plugin • :compile, switch to modulepath when compiling module-info.java • :test-compile, switch to modulepath + classpath when target/classes/module- info.class exists
  • 41.
  • 42. Discover moduleName • Documentation • Central/Repository Managers? Archiva/Artifactory/Nexus • maven-dependency-plugin:list
  • 43.
  • 44. For library/framework/maven-plugin/… builders • The lower the supported Java version, the more projects can use it • The lower the supported Java version, the less Java features can be used. Can we add module-info? Yes!
  • 45. Backwards compatible libraries • module-info (-release 9) • (other) java sources (source/target < 9) • Multi Release JAR? • 2 Execution blocks? • Maven-compiler-plugin magic? Vote NO
  • 46. Dependencies and classpath • Classpath order: – all direct dependencies – all first level indirect dependencies – all second level indirect dependencies – … • Locating a class: iterate over classpath (in same order); first match wins
  • 47. Dependencies and modulepath • Modulepath: packages are mapped to a module – Duplicate packages will result in an Exception • Locating a class: find module based on package; get class from module
  • 48. GOTCHA: Dependency Excludes javac --limit-modules <module>(,<module>)* JAR required to discover moduleName Maven excludes dependencies upfront, no need to download pom/jar. No solution yet; workaround: <arguments/>
  • 49. Are we ready? Java Platform Module System: Issue Summary http://openjdk.java.net/projects/jigsaw/spec/issues/
  • 50. maven-shade-plugin This plugin provides the capability to package the artifact in an uber-jar, including its dependencies and to shade - i.e. rename the packages of some of the dependencies. • Merging module-info files will break encapsulation • Relocation
  • 51. Animal-sniffer signatures • Per module? • Still required now that we have –release?
  • 52. Is my project Java9-ready? • Is it using internal classes? – maven-jdeps-plugin-3.0.0 • Does it have duplicate – extra-enforcer-rule > banDuplicateClasses • Does it require certain Java9 features – Upgrade the matching plugins
  • 53. The Apache Maven project tasklist • Most features should work with Maven 3.0 • Some require Maven 3.3.1 due to improved toolchains support • Large number of new features already developed in plugins, though not always released. • New recipes “The Maven Way™”
  • 54. Developer awareness • Module-info.java triggers modulepath • test-compile uses both modulepath (main/java) and classpath (test/java) • When Java9/Jigsaw fails: – Usage internal APIs – Duplicate (exported) packages
  • 56. Thank you Give it a try! Send feedback, issues & wishes