SlideShare ist ein Scribd-Unternehmen logo
1 von 54
© Copyright Azul Systems 2016
© Copyright Azul Systems 2015
@speakjava
Project Jigsaw in JDK 9:
Modularity Comes To Java
Simon Ritter
Deputy CTO, Azul Systems
1
© Copyright Azul Systems 2016
Agenda
 API structure changes
 Introduction to Jigsaw
 Developing code with modules
 Application migration
 Resources
2
© Copyright Azul Systems 2016
API Structure Changes
© Copyright Azul Systems 2016
API Classification
 Supported, intended for public use
– JCP specified: java.*, javax.*
– JDK specific: some com.sun.*, some jdk.*
 Unsupported, not intended for public use
– Mostly sun.*
– Most infamous is sun.misc.Unsafe
4
© Copyright Azul Systems 2016
General Java Compatability Policy
 If an application uses only supported APIs on version N of
Java it should work on version N+1, even without
recompilation
 Supported APIs can be removed, but only with advanced
notice
 To date 23 classes, 18 interfaces and 379 methods have
been deprecated
–None have been removed
5
© Copyright Azul Systems 2016
JDK 9: Incompatible Changes
 Encapsulate most JDK internal APIs
 Remove a small number of supported APIs
– 6 in total, all add/remove PropertyChangeListener
– Already flagged in JSR 337 (Java SE 8), JEP 162
 Change the binary structure of the JRE and JDK
 New version string format
 A single underscore will no longer be allowed as an
identifier in source code
6
© Copyright Azul Systems 2016
Removed In JDK 9
 Endorsed standard API override mechanism
 Extension mechanism
 No longer required now we have a module system
7
© Copyright Azul Systems 2016
Binary Structure Of JDK/JRE
 Potentially disruptive change
– Details in JEP 220
– Blurs the distinction between JRE and JDK
 Implemented since late 2014
– Allow people to get used to new organisation
8
© Copyright Azul Systems 2016
JDK Structure
bin
Pre-JDK 9 JDK 9
lib
tools.jar
jre
bin
rt.jar
lib
libconfbin
jre directory
tools.jar
rt.jar
© Copyright Azul Systems 2016
Most Popular Unsupported APIs
1. sun.misc.BASE64Encoder
2. sun.misc.Unsafe
3. sun.misc.BASE64Decoder
10
Oracle dataset based on internal application code
© Copyright Azul Systems 2016
JDK Internal API Classification
 Non-critical
– Little or no use outside the JDK
– Used only for convenience (alternatives exist)
 Critical
– Functionality that would be difficult, if not impossible to
implement outside the JDK
11
© Copyright Azul Systems 2016
JEP 260 Proposal
 Encapsulate all non-critical JDK-internal APIs
 Encapsulate all critical JDK-internal APIs, for which
supported replacements exist in JDK 8
 Do not encapsulate other critical JDK-internal APIs
– Deprecate these in JDK 9
– Plan to encapsulate or remove them in JDK 10
– Provide command-line option to access encapsulated
critical APIs
12
© Copyright Azul Systems 2016
JEP 260 Accessible Critical APIs
 sun.misc.Unsafe
 sun.misc.Signal
 sun.misc.SignalHandler
 sun.misc.Cleaner
 sun.reflect.Reflection.getCallerClass
 sun.reflect.ReflectionFactory
13
© Copyright Azul Systems 2016
Reviewing Your Own Code
 jdeps tool
– Introduced in JDK 8, improved in JDK 9
– Maven jdeps plugin
jdeps –jdkinternals path/myapp.jar
14
path/myapp.jar -> /opt/jdk1.8.0/jre/lib/rt.jar
<unnamed> (myapp.jar)
-> java.awt
-> java.awt.event
-> java.beans
-> java.io
...
© Copyright Azul Systems 2016
Introduction To Jigsaw And
Modules
© Copyright Azul Systems 2016
Goals For Project Jigsaw
 Make Java SE more scalable and flexible
 Improve security, maintainability and performance
 Simplify construction, deployment and maintenance of
large scale applications
 Eliminate classpath hell
16
© Copyright Azul Systems 2016
Modularity Specifications
 Java Platform Module System
– JSR 376: Targeted for JDK 9 (no promises)
 Java SE 9: New JSR will cover modularisation of APIs
 OpenJDK Project Jigsaw
 Reference implementation for JSR 376
 JEP 200: The modular JDK
 JEP 201: Modular source code
 JEP 220: Modular run-time images
 JEP 260: Encapsulate most internal APIs
 JEP 261: Module system
17
© Copyright Azul Systems 2016
Module Fundamentals
 Module is a grouping of code
– For Java this is a collection of packages
 The module can contain other things
– Native code
– Resources
– Configuration data
18
com.azul.zoop
com.azul.zoop.alpha.Name
com.azul.zoop.alpha.Position
com.azul.zoop.beta.Animal
com.azul.zoop.beta.Zoo
© Copyright Azul Systems 2016
Module Declaration
19
module com.azul.zoop {
}
module-info.java
com/azul/zoop/alpha/Name.java
com/azul/zoop/alpha/Position.java
com/azul/zoop/beta/Animal.java
com/azul/zoop/beta/Zoo.java
© Copyright Azul Systems 2016
Module Dependencies
module com.azul.zoop {
requires com.azul.zeta;
} com.azul.zoop
com.azul.zeta
© Copyright Azul Systems 2016
Module Dependencies
module com.azul.app {
requires com.azul.zoop
requires java.sql
}
com.azul.app
com.azul.zoop java.sql
© Copyright Azul Systems 2016
Module Dependency Graph
com.azul.app
java.base
java.sqlcom.azul.zoop
com.azul.zeta
java.xml java.logging
explicit
implicit
© Copyright Azul Systems 2016
Readability v. Dependency
com.azul.app
java.sql
java.logging
module java.sql {
requires public java.logging;
}
Driver d = …
Logger l = d.getParentLogger();
l.log(“azul’);
© Copyright Azul Systems 2016
Module Implied Readability Graph
com.azul.app
java.base
java.sqlcom.azul.zoop
com.azul.zeta
java.xml java.logging
© Copyright Azul Systems 2016
Package Visibility
module com.azul.zoop {
exports com.azul.zoop.alpha;
exports com.azul.zoop.beta;
}
com.azul.zoop
com.azul.zoop.alpha
com.azul.zoop.beta com.azul.zoop.theta
© Copyright Azul Systems 2016
Accessibility
 For a package to be visible
– The package must be exported by the containing module
– The containing module must be read by the using module
 Public types from those packages can then be used
com.azul.zoopcom.azul.app
reads
© Copyright Azul Systems 2016
Java Accessibility (pre-JDK 9)
public
protected
<package>
private
© Copyright Azul Systems 2016
Java Accessibility (JDK 9)
public to everyone
public, but only to specific modules
public only within a module
protected
<package>
private
public ≠ accessible (fundamental change to Java)
© Copyright Azul Systems 2016
JDK Platform Modules
29
© Copyright Azul Systems 2016
Developing Code With
Modules
© Copyright Azul Systems 2016
Compilation
31
$ javac –d mods 
src/zeta/module-info.java 
src/zeta/com/azul/zeta/Vehicle.java
mods/zeta/module-info.class
mods/zeta/com/azul/zeta/Vehicle.class
src/zeta/module-info.java
src/zeta/com/azul/zeta/Vehicle.java
© Copyright Azul Systems 2016
Module Path
$ javac –modulepath dir1:dir2:dir3
© Copyright Azul Systems 2016
Compilation With Module Path
33
$ javac –modulepath mods –d mods 
src/zoop/module-info.java 
src/zoop/com/azul/zoop/alpha/Name.java
mods/zoop/module-info.class
mods/zoop/com/azul/zoop/alpha/Name.class
src/zoop/module-info.java
src/zoop/com/azul/zoop/alpha/Name.java
© Copyright Azul Systems 2016
Application Execution
 -modulepath can be abbreviated to -mp
$ java –mp mods –m com.azul.app/com.azul.app.Main
Azul application initialised!
module name main class
© Copyright Azul Systems 2016
Packaging With Modular JAR Files
mods/zoop/module-info.class
mods/zoop/com/azul/app/Main.class
$ jar --create --file myLib/app.jar 
--main-class com.azul.zoop.Main 
-C mods .
module-info.class
com/azul/zoop/Main.class
app.jar
© Copyright Azul Systems 2016
JAR Files & Module Information
$ jar --file myLib/app.jar –p
Name:
com.azul.zoop
Requires:
com.azul.zeta
java.base [MANDATED]
java.sql
Main class:
com.azul.zoop.Main
© Copyright Azul Systems 2016
Application Execution (JAR)
$ java –mp mylib:mods –m com.azul.zoop.Main
Azul application initialised!
© Copyright Azul Systems 2016
Linking
Modular run-time
image
…confbin
jlink
$ jlink --modulepath $JDKMODS 
--addmods java.base –output myimage
$ myimage/bin/java –listmods
java.base@9.0
© Copyright Azul Systems 2016
Linking An Application
$ jlink --modulepath $JDKMODS:$MYMODS 
--addmods com.azul.app –output myimage
$ myimage/bin/java –listmods
java.base@9.0
java.logging@9.0
java.sql@9.0
java.xml@9.0
com.azul.app@1.0
com.azul.zoop@1.0
com.azul.zeta@1.0
Version numbering for
information purposes
only
© Copyright Azul Systems 2016
Application Migration
© Copyright Azul Systems 2016
Typical Application (JDK 8)
jar
jar
jar
JDK
jar
jarjar
jar jar
jar
jar
jar
jar
Classpath
© Copyright Azul Systems 2016
Typical Application (JDK 9)
jar
jar
jar
module
java.base
module
java.desktop
module
java.datatransfer
module
java.xml
jar
jarjar
jar jar
jar
jar
jar
jar
Unnamed
module
© Copyright Azul Systems 2016
Sample Application
myapp.ja
r
lwjgl.jar
mylib.jar
gluegen-rt.jar jogl-all.jar
module
java.base
module
java.desktop
module
java.datatransfer
module
java.xml
© Copyright Azul Systems 2016
Run Application With Classpath
$ java –classpath 
lib/myapp.jar: 
lib/mylib.jar: 
lib/liblwjgl.jar: 
lib/gluegen-rt.jar: 
lib/jogl-all.jar: 
myapp.Main
© Copyright Azul Systems 2016
Sample Application
module
myapp.ja
r
lwjgl.jar
module
mylib.jar
gluegen-rt.jar jogl-all.jar
module
java.base
module
java.desktop
module
java.datatransfer
module
java.xml
© Copyright Azul Systems 2016
Application module-info.java
module myapp {
requires mylib;
requires java.base;
requires java.sql;
requires lwjgl; ????
requires gluegen-rt; ????
requires jogl-all; ????
}
© Copyright Azul Systems 2016
Sample Application
module
myapp.ja
r
module
lwjgl.jar
module
mylib.jar
module
gluegen-rt.jar
module
jogl-all.jar
module
java.base
module
java.desktop
module
java.datatransfer
module
java.xml
© Copyright Azul Systems 2016
Automatic Modules
 Real modules
 Simply place unmodified jar file on module path
– Rather than classpath
 No changes to JAR file
 Module name derived from JAR file name
 Exports all its packages
– No selectivity
 Automatically requires all modules on the module path
48
© Copyright Azul Systems 2016
Application Module Dependencies
module
myapp.ja
r
module
lwjgl.jar
module
mylib.jar
module
gluegen-rt.jar
module
jogl-all.jar
module
java.base
module
java.desktop
module
java.datatransfer
module
java.xml
Implicit
Explicit
© Copyright Azul Systems 2016
Run Application With Modules
$ java –classpath 
lib/myapp.jar: 
lib/mylib.jar: 
lib/liblwjgl.jar: 
lib/gluegen-rt.jar: 
lib/jogl-all.jar: 
myapp.Main
$ java –mp mylib:lib –m myapp
© Copyright Azul Systems 2016
Summary & Further Information
© Copyright Azul Systems 2016
Summary
 Modularisation is a big change for Java
– JVM/JRE rather than language/APIs
 Potentially disruptive changes to exposure of non-public APIs
– Is it safe?
 Developing modular code will require some learning
– Not a huge change, though
52
© Copyright Azul Systems 2016
Further Information
 openjdk.java.net
 openjdk.java.net/jeps
 openjdk.java.net/projects/jigsaw
 jcp.org
www.zulu.org
54
© Copyright Azul Systems 2016
© Copyright Azul Systems 2015
@speakjava
Questions
Simon Ritter
Deputy CTO, Azul Systems
55

Weitere ähnliche Inhalte

Was ist angesagt?

Lambdas and Streams in Java SE 8: Making Bulk Operations simple - Simon Ritter
Lambdas and Streams in Java SE 8: Making Bulk Operations simple - Simon RitterLambdas and Streams in Java SE 8: Making Bulk Operations simple - Simon Ritter
Lambdas and Streams in Java SE 8: Making Bulk Operations simple - Simon RitterJAXLondon2014
 
Lessons Learnt With Lambdas and Streams in JDK 8
Lessons Learnt With Lambdas and Streams in JDK 8Lessons Learnt With Lambdas and Streams in JDK 8
Lessons Learnt With Lambdas and Streams in JDK 8Simon Ritter
 
What's New in Java 8
What's New in Java 8What's New in Java 8
What's New in Java 8javafxpert
 
Oracle Keynote from JMagghreb 2014
Oracle Keynote from JMagghreb 2014Oracle Keynote from JMagghreb 2014
Oracle Keynote from JMagghreb 2014Simon Ritter
 
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
 
Lambdas Hands On Lab
Lambdas Hands On LabLambdas Hands On Lab
Lambdas Hands On LabSimon Ritter
 
Whats New in Java 5, 6, & 7 (Webinar Presentation - June 2013)
Whats New in Java 5, 6, & 7 (Webinar Presentation - June 2013)Whats New in Java 5, 6, & 7 (Webinar Presentation - June 2013)
Whats New in Java 5, 6, & 7 (Webinar Presentation - June 2013)DevelopIntelligence
 
Java SE 8 - New Features
Java SE 8 - New FeaturesJava SE 8 - New Features
Java SE 8 - New FeaturesNaveen Hegde
 
Java 12 - New features in action
Java 12 -   New features in actionJava 12 -   New features in action
Java 12 - New features in actionMarco Molteni
 
The latest features coming to Java 12
The latest features coming to Java 12The latest features coming to Java 12
The latest features coming to Java 12NexSoftsys
 
Introduction of Java 8 with emphasis on Lambda Expressions and Streams
Introduction of Java 8 with emphasis on Lambda Expressions and StreamsIntroduction of Java 8 with emphasis on Lambda Expressions and Streams
Introduction of Java 8 with emphasis on Lambda Expressions and StreamsEmiel Paasschens
 

Was ist angesagt? (20)

Apouc 2014-java-8-create-the-future
Apouc 2014-java-8-create-the-futureApouc 2014-java-8-create-the-future
Apouc 2014-java-8-create-the-future
 
Java 8 Features
Java 8 FeaturesJava 8 Features
Java 8 Features
 
Lambdas and Streams in Java SE 8: Making Bulk Operations simple - Simon Ritter
Lambdas and Streams in Java SE 8: Making Bulk Operations simple - Simon RitterLambdas and Streams in Java SE 8: Making Bulk Operations simple - Simon Ritter
Lambdas and Streams in Java SE 8: Making Bulk Operations simple - Simon Ritter
 
Java SE 8 library design
Java SE 8 library designJava SE 8 library design
Java SE 8 library design
 
Introduction to new features in java 8
Introduction to new features in java 8Introduction to new features in java 8
Introduction to new features in java 8
 
Lessons Learnt With Lambdas and Streams in JDK 8
Lessons Learnt With Lambdas and Streams in JDK 8Lessons Learnt With Lambdas and Streams in JDK 8
Lessons Learnt With Lambdas and Streams in JDK 8
 
What's New in Java 8
What's New in Java 8What's New in Java 8
What's New in Java 8
 
Oracle Keynote from JMagghreb 2014
Oracle Keynote from JMagghreb 2014Oracle Keynote from JMagghreb 2014
Oracle Keynote from JMagghreb 2014
 
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
 
Lambdas Hands On Lab
Lambdas Hands On LabLambdas Hands On Lab
Lambdas Hands On Lab
 
Whats New in Java 5, 6, & 7 (Webinar Presentation - June 2013)
Whats New in Java 5, 6, & 7 (Webinar Presentation - June 2013)Whats New in Java 5, 6, & 7 (Webinar Presentation - June 2013)
Whats New in Java 5, 6, & 7 (Webinar Presentation - June 2013)
 
Java 8 features
Java 8 featuresJava 8 features
Java 8 features
 
Java 8 Features
Java 8 FeaturesJava 8 Features
Java 8 Features
 
Java SE 8 best practices
Java SE 8 best practicesJava SE 8 best practices
Java SE 8 best practices
 
Java 101
Java 101Java 101
Java 101
 
Java SE 8 - New Features
Java SE 8 - New FeaturesJava SE 8 - New Features
Java SE 8 - New Features
 
Java 12 - New features in action
Java 12 -   New features in actionJava 12 -   New features in action
Java 12 - New features in action
 
The latest features coming to Java 12
The latest features coming to Java 12The latest features coming to Java 12
The latest features coming to Java 12
 
Introduction of Java 8 with emphasis on Lambda Expressions and Streams
Introduction of Java 8 with emphasis on Lambda Expressions and StreamsIntroduction of Java 8 with emphasis on Lambda Expressions and Streams
Introduction of Java 8 with emphasis on Lambda Expressions and Streams
 
JDK8 Streams
JDK8 StreamsJDK8 Streams
JDK8 Streams
 

Andere mochten auch

55 New Features in JDK 9
55 New Features in JDK 955 New Features in JDK 9
55 New Features in JDK 9Simon Ritter
 
Is An Agile Standard Possible For Java?
Is An Agile Standard Possible For Java?Is An Agile Standard Possible For Java?
Is An Agile Standard Possible For Java?Simon Ritter
 
It's Java Jim, But Not As We Know It!
It's Java Jim, But Not As We Know It!It's Java Jim, But Not As We Know It!
It's Java Jim, But Not As We Know It!Simon Ritter
 
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
 
Lambdas And Streams Hands On Lab, JavaOne 2014
Lambdas And Streams Hands On Lab, JavaOne 2014Lambdas And Streams Hands On Lab, JavaOne 2014
Lambdas And Streams Hands On Lab, JavaOne 2014Simon Ritter
 
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
 

Andere mochten auch (7)

55 New Features in JDK 9
55 New Features in JDK 955 New Features in JDK 9
55 New Features in JDK 9
 
Is An Agile Standard Possible For Java?
Is An Agile Standard Possible For Java?Is An Agile Standard Possible For Java?
Is An Agile Standard Possible For Java?
 
It's Java Jim, But Not As We Know It!
It's Java Jim, But Not As We Know It!It's Java Jim, But Not As We Know It!
It's Java Jim, But Not As We Know It!
 
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
 
Java 9 preview
Java 9 previewJava 9 preview
Java 9 preview
 
Lambdas And Streams Hands On Lab, JavaOne 2014
Lambdas And Streams Hands On Lab, JavaOne 2014Lambdas And Streams Hands On Lab, JavaOne 2014
Lambdas And Streams Hands On Lab, JavaOne 2014
 
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
 

Ähnlich wie Project Jigsaw in JDK9

Voxxed Days Thessaloniki 2016 - JDK 9 : Big Changes To Make Java Smaller
Voxxed Days Thessaloniki 2016 - JDK 9 : Big Changes To Make Java Smaller Voxxed Days Thessaloniki 2016 - JDK 9 : Big Changes To Make Java Smaller
Voxxed Days Thessaloniki 2016 - JDK 9 : Big Changes To Make Java Smaller Patroklos Papapetrou (Pat)
 
Voxxed Days Thessaloniki 2016 - Keynote - JDK 9 : Big Changes To Make Java Sm...
Voxxed Days Thessaloniki 2016 - Keynote - JDK 9 : Big Changes To Make Java Sm...Voxxed Days Thessaloniki 2016 - Keynote - JDK 9 : Big Changes To Make Java Sm...
Voxxed Days Thessaloniki 2016 - Keynote - JDK 9 : Big Changes To Make Java Sm...Voxxed Days Thessaloniki
 
JDK 9 and JDK 10 Deep Dive
JDK 9 and JDK 10 Deep DiveJDK 9 and JDK 10 Deep Dive
JDK 9 and JDK 10 Deep DiveSimon Ritter
 
Project Jigsaw in JDK 9: Modularity Comes To Java
Project Jigsaw in JDK 9: Modularity Comes To JavaProject Jigsaw in JDK 9: Modularity Comes To Java
Project Jigsaw in JDK 9: Modularity Comes To JavaC4Media
 
Modern Java Workshop
Modern Java WorkshopModern Java Workshop
Modern Java WorkshopSimon Ritter
 
JDK 9: The Start of a New Future for Java
JDK 9: The Start of a New Future for JavaJDK 9: The Start of a New Future for Java
JDK 9: The Start of a New Future for JavaSimon Ritter
 
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
 
Moving Towards JDK 12
Moving Towards JDK 12Moving Towards JDK 12
Moving Towards JDK 12Simon Ritter
 
JDK 9: Migrating Applications
JDK 9: Migrating ApplicationsJDK 9: Migrating Applications
JDK 9: Migrating ApplicationsSimon Ritter
 
JDK 9, 10, 11 and Beyond
JDK 9, 10, 11 and BeyondJDK 9, 10, 11 and Beyond
JDK 9, 10, 11 and BeyondSimon Ritter
 
Serverless Java: JJUG CCC 2019
Serverless Java: JJUG CCC 2019Serverless Java: JJUG CCC 2019
Serverless Java: JJUG CCC 2019Shaun Smith
 
Preparing your code for Java 9
Preparing your code for Java 9Preparing your code for Java 9
Preparing your code for Java 9Deepu Xavier
 
10 Tips for Java EE 7 with PrimeFaces - JavaOne 2013
10 Tips for Java EE 7 with PrimeFaces - JavaOne 201310 Tips for Java EE 7 with PrimeFaces - JavaOne 2013
10 Tips for Java EE 7 with PrimeFaces - JavaOne 2013Martin Fousek
 
JDK 9, 10, 11 and Beyond
JDK 9, 10, 11 and BeyondJDK 9, 10, 11 and Beyond
JDK 9, 10, 11 and BeyondSimon Ritter
 

Ähnlich wie Project Jigsaw in JDK9 (20)

Voxxed Days Thessaloniki 2016 - JDK 9 : Big Changes To Make Java Smaller
Voxxed Days Thessaloniki 2016 - JDK 9 : Big Changes To Make Java Smaller Voxxed Days Thessaloniki 2016 - JDK 9 : Big Changes To Make Java Smaller
Voxxed Days Thessaloniki 2016 - JDK 9 : Big Changes To Make Java Smaller
 
Voxxed Days Thessaloniki 2016 - Keynote - JDK 9 : Big Changes To Make Java Sm...
Voxxed Days Thessaloniki 2016 - Keynote - JDK 9 : Big Changes To Make Java Sm...Voxxed Days Thessaloniki 2016 - Keynote - JDK 9 : Big Changes To Make Java Sm...
Voxxed Days Thessaloniki 2016 - Keynote - JDK 9 : Big Changes To Make Java Sm...
 
JDK 9 Deep Dive
JDK 9 Deep DiveJDK 9 Deep Dive
JDK 9 Deep Dive
 
JDK 9 and JDK 10 Deep Dive
JDK 9 and JDK 10 Deep DiveJDK 9 and JDK 10 Deep Dive
JDK 9 and JDK 10 Deep Dive
 
Project Jigsaw in JDK 9: Modularity Comes To Java
Project Jigsaw in JDK 9: Modularity Comes To JavaProject Jigsaw in JDK 9: Modularity Comes To Java
Project Jigsaw in JDK 9: Modularity Comes To Java
 
Modern Java Workshop
Modern Java WorkshopModern Java Workshop
Modern Java Workshop
 
Jigsaw modularity
Jigsaw modularityJigsaw modularity
Jigsaw modularity
 
JDK 9: The Start of a New Future for Java
JDK 9: The Start of a New Future for JavaJDK 9: The Start of a New Future for Java
JDK 9: The Start of a New Future 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?
JDK 9: Mission Accomplished. What Next For Java?
 
Advanced modular development
Advanced modular development  Advanced modular development
Advanced modular development
 
JDK-9: Modules and Java Linker
JDK-9: Modules and Java LinkerJDK-9: Modules and Java Linker
JDK-9: Modules and Java Linker
 
Moving Towards JDK 12
Moving Towards JDK 12Moving Towards JDK 12
Moving Towards JDK 12
 
JDK 9: Migrating Applications
JDK 9: Migrating ApplicationsJDK 9: Migrating Applications
JDK 9: Migrating Applications
 
JDK 9, 10, 11 and Beyond
JDK 9, 10, 11 and BeyondJDK 9, 10, 11 and Beyond
JDK 9, 10, 11 and Beyond
 
Serverless Java: JJUG CCC 2019
Serverless Java: JJUG CCC 2019Serverless Java: JJUG CCC 2019
Serverless Java: JJUG CCC 2019
 
Preparing your code for Java 9
Preparing your code for Java 9Preparing your code for Java 9
Preparing your code for Java 9
 
JDK 10 Java Module System
JDK 10 Java Module SystemJDK 10 Java Module System
JDK 10 Java Module System
 
10 Tips for Java EE 7 with PrimeFaces - JavaOne 2013
10 Tips for Java EE 7 with PrimeFaces - JavaOne 201310 Tips for Java EE 7 with PrimeFaces - JavaOne 2013
10 Tips for Java EE 7 with PrimeFaces - JavaOne 2013
 
JDK 9, 10, 11 and Beyond
JDK 9, 10, 11 and BeyondJDK 9, 10, 11 and Beyond
JDK 9, 10, 11 and Beyond
 
Modularization in java 8
Modularization in java 8Modularization in java 8
Modularization in java 8
 

Mehr von Simon Ritter

Cloud Native Compiler
Cloud Native CompilerCloud Native Compiler
Cloud Native CompilerSimon Ritter
 
The Art of Java Type Patterns
The Art of Java Type PatternsThe Art of Java Type Patterns
The Art of Java Type PatternsSimon Ritter
 
Modern Java Workshop
Modern Java WorkshopModern Java Workshop
Modern Java WorkshopSimon Ritter
 
Java performance monitoring
Java performance monitoringJava performance monitoring
Java performance monitoringSimon Ritter
 
Getting the Most From Modern Java
Getting the Most From Modern JavaGetting the Most From Modern Java
Getting the Most From Modern JavaSimon Ritter
 
Building a Better JVM
Building a Better JVMBuilding a Better JVM
Building a Better JVMSimon Ritter
 
JDK 14 Lots of New Features
JDK 14 Lots of New FeaturesJDK 14 Lots of New Features
JDK 14 Lots of New FeaturesSimon Ritter
 
How to Choose a JDK
How to Choose a JDKHow to Choose a JDK
How to Choose a JDKSimon Ritter
 
The Latest in Enterprise JavaBeans Technology
The Latest in Enterprise JavaBeans TechnologyThe Latest in Enterprise JavaBeans Technology
The Latest in Enterprise JavaBeans TechnologySimon Ritter
 
Developing Enterprise Applications Using Java Technology
Developing Enterprise Applications Using Java TechnologyDeveloping Enterprise Applications Using Java Technology
Developing Enterprise Applications Using Java TechnologySimon Ritter
 
Is Java Still Free?
Is Java Still Free?Is Java Still Free?
Is Java Still Free?Simon Ritter
 
Java Is Still Free
Java Is Still FreeJava Is Still Free
Java Is Still FreeSimon Ritter
 
Java Support: What's changing
Java Support:  What's changingJava Support:  What's changing
Java Support: What's changingSimon Ritter
 
Building a Brain with Raspberry Pi and Zulu Embedded JVM
Building a Brain with Raspberry Pi and Zulu Embedded JVMBuilding a Brain with Raspberry Pi and Zulu Embedded JVM
Building a Brain with Raspberry Pi and Zulu Embedded JVMSimon Ritter
 
It's Java, Jim, but not as we know it
It's Java, Jim, but not as we know itIt's Java, Jim, but not as we know it
It's Java, Jim, but not as we know itSimon Ritter
 
Whats New For Developers In JDK 9
Whats New For Developers In JDK 9Whats New For Developers In JDK 9
Whats New For Developers In JDK 9Simon Ritter
 
JDK 9: 55 New Features
JDK 9: 55 New FeaturesJDK 9: 55 New Features
JDK 9: 55 New FeaturesSimon Ritter
 

Mehr von Simon Ritter (20)

Cloud Native Compiler
Cloud Native CompilerCloud Native Compiler
Cloud Native Compiler
 
Java On CRaC
Java On CRaCJava On CRaC
Java On CRaC
 
The Art of Java Type Patterns
The Art of Java Type PatternsThe Art of Java Type Patterns
The Art of Java Type Patterns
 
Modern Java Workshop
Modern Java WorkshopModern Java Workshop
Modern Java Workshop
 
Java performance monitoring
Java performance monitoringJava performance monitoring
Java performance monitoring
 
Getting the Most From Modern Java
Getting the Most From Modern JavaGetting the Most From Modern Java
Getting the Most From Modern Java
 
Building a Better JVM
Building a Better JVMBuilding a Better JVM
Building a Better JVM
 
JDK 14 Lots of New Features
JDK 14 Lots of New FeaturesJDK 14 Lots of New Features
JDK 14 Lots of New Features
 
Java after 8
Java after 8Java after 8
Java after 8
 
How to Choose a JDK
How to Choose a JDKHow to Choose a JDK
How to Choose a JDK
 
Java Programming
Java ProgrammingJava Programming
Java Programming
 
The Latest in Enterprise JavaBeans Technology
The Latest in Enterprise JavaBeans TechnologyThe Latest in Enterprise JavaBeans Technology
The Latest in Enterprise JavaBeans Technology
 
Developing Enterprise Applications Using Java Technology
Developing Enterprise Applications Using Java TechnologyDeveloping Enterprise Applications Using Java Technology
Developing Enterprise Applications Using Java Technology
 
Is Java Still Free?
Is Java Still Free?Is Java Still Free?
Is Java Still Free?
 
Java Is Still Free
Java Is Still FreeJava Is Still Free
Java Is Still Free
 
Java Support: What's changing
Java Support:  What's changingJava Support:  What's changing
Java Support: What's changing
 
Building a Brain with Raspberry Pi and Zulu Embedded JVM
Building a Brain with Raspberry Pi and Zulu Embedded JVMBuilding a Brain with Raspberry Pi and Zulu Embedded JVM
Building a Brain with Raspberry Pi and Zulu Embedded JVM
 
It's Java, Jim, but not as we know it
It's Java, Jim, but not as we know itIt's Java, Jim, but not as we know it
It's Java, Jim, but not as we know it
 
Whats New For Developers In JDK 9
Whats New For Developers In JDK 9Whats New For Developers In JDK 9
Whats New For Developers In JDK 9
 
JDK 9: 55 New Features
JDK 9: 55 New FeaturesJDK 9: 55 New Features
JDK 9: 55 New Features
 

Kürzlich hochgeladen

Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendArshad QA
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
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
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
(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
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 

Kürzlich hochgeladen (20)

Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and Backend
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
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...
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
(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...
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 

Project Jigsaw in JDK9

  • 1. © Copyright Azul Systems 2016 © Copyright Azul Systems 2015 @speakjava Project Jigsaw in JDK 9: Modularity Comes To Java Simon Ritter Deputy CTO, Azul Systems 1
  • 2. © Copyright Azul Systems 2016 Agenda  API structure changes  Introduction to Jigsaw  Developing code with modules  Application migration  Resources 2
  • 3. © Copyright Azul Systems 2016 API Structure Changes
  • 4. © Copyright Azul Systems 2016 API Classification  Supported, intended for public use – JCP specified: java.*, javax.* – JDK specific: some com.sun.*, some jdk.*  Unsupported, not intended for public use – Mostly sun.* – Most infamous is sun.misc.Unsafe 4
  • 5. © Copyright Azul Systems 2016 General Java Compatability Policy  If an application uses only supported APIs on version N of Java it should work on version N+1, even without recompilation  Supported APIs can be removed, but only with advanced notice  To date 23 classes, 18 interfaces and 379 methods have been deprecated –None have been removed 5
  • 6. © Copyright Azul Systems 2016 JDK 9: Incompatible Changes  Encapsulate most JDK internal APIs  Remove a small number of supported APIs – 6 in total, all add/remove PropertyChangeListener – Already flagged in JSR 337 (Java SE 8), JEP 162  Change the binary structure of the JRE and JDK  New version string format  A single underscore will no longer be allowed as an identifier in source code 6
  • 7. © Copyright Azul Systems 2016 Removed In JDK 9  Endorsed standard API override mechanism  Extension mechanism  No longer required now we have a module system 7
  • 8. © Copyright Azul Systems 2016 Binary Structure Of JDK/JRE  Potentially disruptive change – Details in JEP 220 – Blurs the distinction between JRE and JDK  Implemented since late 2014 – Allow people to get used to new organisation 8
  • 9. © Copyright Azul Systems 2016 JDK Structure bin Pre-JDK 9 JDK 9 lib tools.jar jre bin rt.jar lib libconfbin jre directory tools.jar rt.jar
  • 10. © Copyright Azul Systems 2016 Most Popular Unsupported APIs 1. sun.misc.BASE64Encoder 2. sun.misc.Unsafe 3. sun.misc.BASE64Decoder 10 Oracle dataset based on internal application code
  • 11. © Copyright Azul Systems 2016 JDK Internal API Classification  Non-critical – Little or no use outside the JDK – Used only for convenience (alternatives exist)  Critical – Functionality that would be difficult, if not impossible to implement outside the JDK 11
  • 12. © Copyright Azul Systems 2016 JEP 260 Proposal  Encapsulate all non-critical JDK-internal APIs  Encapsulate all critical JDK-internal APIs, for which supported replacements exist in JDK 8  Do not encapsulate other critical JDK-internal APIs – Deprecate these in JDK 9 – Plan to encapsulate or remove them in JDK 10 – Provide command-line option to access encapsulated critical APIs 12
  • 13. © Copyright Azul Systems 2016 JEP 260 Accessible Critical APIs  sun.misc.Unsafe  sun.misc.Signal  sun.misc.SignalHandler  sun.misc.Cleaner  sun.reflect.Reflection.getCallerClass  sun.reflect.ReflectionFactory 13
  • 14. © Copyright Azul Systems 2016 Reviewing Your Own Code  jdeps tool – Introduced in JDK 8, improved in JDK 9 – Maven jdeps plugin jdeps –jdkinternals path/myapp.jar 14 path/myapp.jar -> /opt/jdk1.8.0/jre/lib/rt.jar <unnamed> (myapp.jar) -> java.awt -> java.awt.event -> java.beans -> java.io ...
  • 15. © Copyright Azul Systems 2016 Introduction To Jigsaw And Modules
  • 16. © Copyright Azul Systems 2016 Goals For Project Jigsaw  Make Java SE more scalable and flexible  Improve security, maintainability and performance  Simplify construction, deployment and maintenance of large scale applications  Eliminate classpath hell 16
  • 17. © Copyright Azul Systems 2016 Modularity Specifications  Java Platform Module System – JSR 376: Targeted for JDK 9 (no promises)  Java SE 9: New JSR will cover modularisation of APIs  OpenJDK Project Jigsaw  Reference implementation for JSR 376  JEP 200: The modular JDK  JEP 201: Modular source code  JEP 220: Modular run-time images  JEP 260: Encapsulate most internal APIs  JEP 261: Module system 17
  • 18. © Copyright Azul Systems 2016 Module Fundamentals  Module is a grouping of code – For Java this is a collection of packages  The module can contain other things – Native code – Resources – Configuration data 18 com.azul.zoop com.azul.zoop.alpha.Name com.azul.zoop.alpha.Position com.azul.zoop.beta.Animal com.azul.zoop.beta.Zoo
  • 19. © Copyright Azul Systems 2016 Module Declaration 19 module com.azul.zoop { } module-info.java com/azul/zoop/alpha/Name.java com/azul/zoop/alpha/Position.java com/azul/zoop/beta/Animal.java com/azul/zoop/beta/Zoo.java
  • 20. © Copyright Azul Systems 2016 Module Dependencies module com.azul.zoop { requires com.azul.zeta; } com.azul.zoop com.azul.zeta
  • 21. © Copyright Azul Systems 2016 Module Dependencies module com.azul.app { requires com.azul.zoop requires java.sql } com.azul.app com.azul.zoop java.sql
  • 22. © Copyright Azul Systems 2016 Module Dependency Graph com.azul.app java.base java.sqlcom.azul.zoop com.azul.zeta java.xml java.logging explicit implicit
  • 23. © Copyright Azul Systems 2016 Readability v. Dependency com.azul.app java.sql java.logging module java.sql { requires public java.logging; } Driver d = … Logger l = d.getParentLogger(); l.log(“azul’);
  • 24. © Copyright Azul Systems 2016 Module Implied Readability Graph com.azul.app java.base java.sqlcom.azul.zoop com.azul.zeta java.xml java.logging
  • 25. © Copyright Azul Systems 2016 Package Visibility module com.azul.zoop { exports com.azul.zoop.alpha; exports com.azul.zoop.beta; } com.azul.zoop com.azul.zoop.alpha com.azul.zoop.beta com.azul.zoop.theta
  • 26. © Copyright Azul Systems 2016 Accessibility  For a package to be visible – The package must be exported by the containing module – The containing module must be read by the using module  Public types from those packages can then be used com.azul.zoopcom.azul.app reads
  • 27. © Copyright Azul Systems 2016 Java Accessibility (pre-JDK 9) public protected <package> private
  • 28. © Copyright Azul Systems 2016 Java Accessibility (JDK 9) public to everyone public, but only to specific modules public only within a module protected <package> private public ≠ accessible (fundamental change to Java)
  • 29. © Copyright Azul Systems 2016 JDK Platform Modules 29
  • 30. © Copyright Azul Systems 2016 Developing Code With Modules
  • 31. © Copyright Azul Systems 2016 Compilation 31 $ javac –d mods src/zeta/module-info.java src/zeta/com/azul/zeta/Vehicle.java mods/zeta/module-info.class mods/zeta/com/azul/zeta/Vehicle.class src/zeta/module-info.java src/zeta/com/azul/zeta/Vehicle.java
  • 32. © Copyright Azul Systems 2016 Module Path $ javac –modulepath dir1:dir2:dir3
  • 33. © Copyright Azul Systems 2016 Compilation With Module Path 33 $ javac –modulepath mods –d mods src/zoop/module-info.java src/zoop/com/azul/zoop/alpha/Name.java mods/zoop/module-info.class mods/zoop/com/azul/zoop/alpha/Name.class src/zoop/module-info.java src/zoop/com/azul/zoop/alpha/Name.java
  • 34. © Copyright Azul Systems 2016 Application Execution  -modulepath can be abbreviated to -mp $ java –mp mods –m com.azul.app/com.azul.app.Main Azul application initialised! module name main class
  • 35. © Copyright Azul Systems 2016 Packaging With Modular JAR Files mods/zoop/module-info.class mods/zoop/com/azul/app/Main.class $ jar --create --file myLib/app.jar --main-class com.azul.zoop.Main -C mods . module-info.class com/azul/zoop/Main.class app.jar
  • 36. © Copyright Azul Systems 2016 JAR Files & Module Information $ jar --file myLib/app.jar –p Name: com.azul.zoop Requires: com.azul.zeta java.base [MANDATED] java.sql Main class: com.azul.zoop.Main
  • 37. © Copyright Azul Systems 2016 Application Execution (JAR) $ java –mp mylib:mods –m com.azul.zoop.Main Azul application initialised!
  • 38. © Copyright Azul Systems 2016 Linking Modular run-time image …confbin jlink $ jlink --modulepath $JDKMODS --addmods java.base –output myimage $ myimage/bin/java –listmods java.base@9.0
  • 39. © Copyright Azul Systems 2016 Linking An Application $ jlink --modulepath $JDKMODS:$MYMODS --addmods com.azul.app –output myimage $ myimage/bin/java –listmods java.base@9.0 java.logging@9.0 java.sql@9.0 java.xml@9.0 com.azul.app@1.0 com.azul.zoop@1.0 com.azul.zeta@1.0 Version numbering for information purposes only
  • 40. © Copyright Azul Systems 2016 Application Migration
  • 41. © Copyright Azul Systems 2016 Typical Application (JDK 8) jar jar jar JDK jar jarjar jar jar jar jar jar jar Classpath
  • 42. © Copyright Azul Systems 2016 Typical Application (JDK 9) jar jar jar module java.base module java.desktop module java.datatransfer module java.xml jar jarjar jar jar jar jar jar jar Unnamed module
  • 43. © Copyright Azul Systems 2016 Sample Application myapp.ja r lwjgl.jar mylib.jar gluegen-rt.jar jogl-all.jar module java.base module java.desktop module java.datatransfer module java.xml
  • 44. © Copyright Azul Systems 2016 Run Application With Classpath $ java –classpath lib/myapp.jar: lib/mylib.jar: lib/liblwjgl.jar: lib/gluegen-rt.jar: lib/jogl-all.jar: myapp.Main
  • 45. © Copyright Azul Systems 2016 Sample Application module myapp.ja r lwjgl.jar module mylib.jar gluegen-rt.jar jogl-all.jar module java.base module java.desktop module java.datatransfer module java.xml
  • 46. © Copyright Azul Systems 2016 Application module-info.java module myapp { requires mylib; requires java.base; requires java.sql; requires lwjgl; ???? requires gluegen-rt; ???? requires jogl-all; ???? }
  • 47. © Copyright Azul Systems 2016 Sample Application module myapp.ja r module lwjgl.jar module mylib.jar module gluegen-rt.jar module jogl-all.jar module java.base module java.desktop module java.datatransfer module java.xml
  • 48. © Copyright Azul Systems 2016 Automatic Modules  Real modules  Simply place unmodified jar file on module path – Rather than classpath  No changes to JAR file  Module name derived from JAR file name  Exports all its packages – No selectivity  Automatically requires all modules on the module path 48
  • 49. © Copyright Azul Systems 2016 Application Module Dependencies module myapp.ja r module lwjgl.jar module mylib.jar module gluegen-rt.jar module jogl-all.jar module java.base module java.desktop module java.datatransfer module java.xml Implicit Explicit
  • 50. © Copyright Azul Systems 2016 Run Application With Modules $ java –classpath lib/myapp.jar: lib/mylib.jar: lib/liblwjgl.jar: lib/gluegen-rt.jar: lib/jogl-all.jar: myapp.Main $ java –mp mylib:lib –m myapp
  • 51. © Copyright Azul Systems 2016 Summary & Further Information
  • 52. © Copyright Azul Systems 2016 Summary  Modularisation is a big change for Java – JVM/JRE rather than language/APIs  Potentially disruptive changes to exposure of non-public APIs – Is it safe?  Developing modular code will require some learning – Not a huge change, though 52
  • 53. © Copyright Azul Systems 2016 Further Information  openjdk.java.net  openjdk.java.net/jeps  openjdk.java.net/projects/jigsaw  jcp.org www.zulu.org 54
  • 54. © Copyright Azul Systems 2016 © Copyright Azul Systems 2015 @speakjava Questions Simon Ritter Deputy CTO, Azul Systems 55

Hinweis der Redaktion

  1. com.sun API examples mostly around tooling jdk API example is nashorn
  2. Signal/SignalHandler (handling OS level signals SIGIINT) Cleaner - more flexible alternative to class finalisation Reflection - which classes are in the call stack
  3. JSR 277 Java module system (like OSGi) WITHDRAWN JSR 291 Dynamic component support (IBM) JSR 294 Improved modularity WITHDRAWN