SlideShare a Scribd company logo
© Copyright Azul Systems 2016
© Copyright Azul Systems 2015
@speakjava
Modularization with Project
Jigsaw in JDK 9
Simon Ritter
Deputy CTO, Azul Systems
1
© Copyright Azul Systems 2016
Agenda
 JDK 9 API structure overview
 Introduction to Jigsaw and modules
 Developing code with modules
 Summary and further information
2
© Copyright Azul Systems 2016
JDK 9 API Structure Overview
3
© 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
 See how long you can keep a project going for
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
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
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
 Change the binary structure of the JRE and JDK
 Remove the endorsed-standards override and extension
mechanism
 New version string format
 A single underscore will no longer be allowed as an
identifier in source code
7
© Copyright Azul Systems 2016
Most Popular Unsupported APIs
1. sun.misc.BASE64Encoder
2. sun.misc.Unsafe
3. sun.misc.BASE64Decoder
8
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
9
© Copyright Azul Systems 2016
JEP 260 Proposal
1. Encapsulate all non-critical JDK-internal APIs
2. Encapsulate all critical JDK-internal APIs, for which
supported replacements exist in JDK 8
3. 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
10
© 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
11
© 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
Introduction to Jigsaw and Modules
13
© 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
14
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
15
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
© 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
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 Readability Graph
com.azul.app
java.base
java.sqlcom.azul.zoop
com.azul.zeta
java.xml java.logging
© 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
25
© Copyright Azul Systems 2016
Developing Code With Modules
26
© Copyright Azul Systems 2016
Compilation
27
$ javac –d mods 
src/zeta/module-info.java 
src/zeta/com/azul/zeta/Vehicle.java
mods/zeta/mod-info.class
mods/zeta/com/azul/zeta/Vehicle.class
src/zeta/mod-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
29
$ javac –modulepath mlib –d mods 
src/zoop/module-info.java 
src/zoop/com/azul/zoop/alpha/Name.java
mods/zoop/mod-info.class
mods/zoop/com/azul/zoop/alpha/Name.class
src/zoop/mod-info.java
src/zoop/com/azul/zoop/alpha/Name.java
© Copyright Azul Systems 2016
Application Execution
 -modulepath can be abbreviated to -mp
$ java –modulepath mods –m com.azul.app/com.azul.app.Main
Azul application initialised!
module name main class
© Copyright Azul Systems 2016
Packaging With Modular Jars
mods/app/mod-info.class
mods/app/com/azul/app/Main.class
$ jar --create --file mlib/app.jar 
--main-class com.azul.app.Main 
-C mods .
module-info.class
com/azul/zoop/Main.class
app.jar
© Copyright Azul Systems 2016
Jar Files & Module Information
$ jar --file mlib/app.jar –p
Name:
com.azul.app
Requires:
com.azul.zoop
java.base [MANDATED]
java.sql
Main class:
com.azul.app.Main
© Copyright Azul Systems 2016
Application Execution (JAR)
$ java –mp mlib:mods –m com.azul.app.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
© Copyright Azul Systems 2016
Summary & Further Information
36
© Copyright Azul Systems 2016
Summary
 Modularisation is a big change for Java
– JVM/JRE rather than language/APIs
– Public access isn’t necessarily the same
 Flexibility to define what is exported
 New linking capability to generate runtime image
 More to learn about converting existing code
 Will make all applications simpler to deploy and manage
37
© Copyright Azul Systems 2016
Further Information
 openjdk.java.net
 openjdk.java.net/jeps
– 200, 201, 220, 260, 261
 openjdk.java.net/projects/jigsaw
 jcp.org
– JSR 376
 www.zulu.org (OpenJDK supported builds JDK 6, 7, 8, 9)
 www.azul.com (Zing JVM for low latency)
38
© Copyright Azul Systems 2016
© Copyright Azul Systems 2015
@speakjava
Modularization with Project
Jigsaw in JDK 9
Simon Ritter
Deputy CTO, Azul Systems
39

More Related Content

PPTX
Modularity of the Java Platform (OSGi, Jigsaw and Penrose)
Martin Toshev
 
PDF
JDK-9: Modules and Java Linker
Bhanu Prakash Gopularam
 
PPTX
JDK 9: Big Changes To Make Java Smaller
Simon Ritter
 
PPTX
Java modules using project jigsaw@jdk 9
Mauricio "Maltron" Leal
 
PDF
Oracle Keynote from JMagghreb 2014
Simon Ritter
 
PPTX
Java 9 Modularity and Project Jigsaw
Comsysto Reply GmbH
 
PPTX
JDK 9: Big Changes To Make Java Smaller
Simon Ritter
 
PDF
Java: Create The Future Keynote
Simon Ritter
 
Modularity of the Java Platform (OSGi, Jigsaw and Penrose)
Martin Toshev
 
JDK-9: Modules and Java Linker
Bhanu Prakash Gopularam
 
JDK 9: Big Changes To Make Java Smaller
Simon Ritter
 
Java modules using project jigsaw@jdk 9
Mauricio "Maltron" Leal
 
Oracle Keynote from JMagghreb 2014
Simon Ritter
 
Java 9 Modularity and Project Jigsaw
Comsysto Reply GmbH
 
JDK 9: Big Changes To Make Java Smaller
Simon Ritter
 
Java: Create The Future Keynote
Simon Ritter
 

What's hot (20)

PDF
Java modularity: life after Java 9
Sander Mak (@Sander_Mak)
 
PDF
Java 9 and Project Jigsaw
DPC Consulting Ltd
 
PPTX
Is An Agile Standard Possible For Java?
Simon Ritter
 
PPT
Developing modular Java applications
Julien Dubois
 
PPTX
JDK 9: Mission Accomplished. What Next For Java?
Simon Ritter
 
PDF
Java Modularity: the Year After
Sander Mak (@Sander_Mak)
 
PDF
Java 9 preview
Ivan Krylov
 
PDF
Migrating to Java 9 Modules
Sander Mak (@Sander_Mak)
 
PPTX
55 New Features in JDK 9
Simon Ritter
 
PPTX
Modular Java
Martin Toshev
 
PPTX
JDK 9 Deep Dive
Simon Ritter
 
PPTX
JavaFX 2 Using the Spring Framework
Stephen Chin
 
PDF
Java EE, What's Next? by Anil Gaur
Takashi Ito
 
PPTX
JDK 9: The Start of a New Future for Java
Simon Ritter
 
PPTX
Moving Towards JDK 12
Simon Ritter
 
PDF
Java 2012 conference keynote - Java Strategy & Roadmap - WebLogic & GlassFish...
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
PPTX
The latest features coming to Java 12
NexSoftsys
 
PPTX
JDK 9 and JDK 10 Deep Dive
Simon Ritter
 
PDF
Pitfalls of migrating projects to JDK 9
Pavel Bucek
 
PPSX
Java 9 and the impact on Maven Projects (JavaOne 2016)
Robert Scholte
 
Java modularity: life after Java 9
Sander Mak (@Sander_Mak)
 
Java 9 and Project Jigsaw
DPC Consulting Ltd
 
Is An Agile Standard Possible For Java?
Simon Ritter
 
Developing modular Java applications
Julien Dubois
 
JDK 9: Mission Accomplished. What Next For Java?
Simon Ritter
 
Java Modularity: the Year After
Sander Mak (@Sander_Mak)
 
Java 9 preview
Ivan Krylov
 
Migrating to Java 9 Modules
Sander Mak (@Sander_Mak)
 
55 New Features in JDK 9
Simon Ritter
 
Modular Java
Martin Toshev
 
JDK 9 Deep Dive
Simon Ritter
 
JavaFX 2 Using the Spring Framework
Stephen Chin
 
Java EE, What's Next? by Anil Gaur
Takashi Ito
 
JDK 9: The Start of a New Future for Java
Simon Ritter
 
Moving Towards JDK 12
Simon Ritter
 
Java 2012 conference keynote - Java Strategy & Roadmap - WebLogic & GlassFish...
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
The latest features coming to Java 12
NexSoftsys
 
JDK 9 and JDK 10 Deep Dive
Simon Ritter
 
Pitfalls of migrating projects to JDK 9
Pavel Bucek
 
Java 9 and the impact on Maven Projects (JavaOne 2016)
Robert Scholte
 
Ad

Viewers also liked (20)

PDF
Java 9 – The Ultimate Feature List
Takipi
 
PDF
Java 9 Modularity in Action
Sander Mak (@Sander_Mak)
 
PDF
Jigsaw - Javaforum 2015Q4
Rikard Thulin
 
PDF
OSGi for mere mortals
Bertrand Delacretaz
 
PDF
Reducing technical debt in php
Carola Lilienthal
 
PDF
JFokus Java 9 contended locking performance
Monica Beckwith
 
PPTX
Project Jigsaw in JDK9
Simon Ritter
 
PDF
The Cuddly Throwable Application Server
Holly Cummins
 
PDF
Using Java 8 on Android
Eduardo Felipe Ewert Bonet
 
PDF
Its all about the domain honey
Carola Lilienthal
 
PPTX
Lambdas Hands On Lab
Simon Ritter
 
PPTX
Lessons Learnt With Lambdas and Streams in JDK 8
Simon Ritter
 
PPTX
It's Java Jim, But Not As We Know It!
Simon Ritter
 
PDF
Embracing Reactive Streams with Java 9 and Spring 5
Wilder Rodrigues
 
PPTX
Modules in Java? Finally! (OpenJDK 9 Jigsaw, JSR376)
Mihail Stoynov
 
PDF
Benefits of OSGi in Practise
David Bosschaert
 
PDF
Why OSGi?
bjhargrave
 
PDF
I/O Extended (GDG Bogor) - Andrew Kurniadi
Dicoding
 
PDF
Java9 and Project Jigsaw
takezoe
 
PDF
Project Jigsaw in JDK 9: Modularity Comes To Java
C4Media
 
Java 9 – The Ultimate Feature List
Takipi
 
Java 9 Modularity in Action
Sander Mak (@Sander_Mak)
 
Jigsaw - Javaforum 2015Q4
Rikard Thulin
 
OSGi for mere mortals
Bertrand Delacretaz
 
Reducing technical debt in php
Carola Lilienthal
 
JFokus Java 9 contended locking performance
Monica Beckwith
 
Project Jigsaw in JDK9
Simon Ritter
 
The Cuddly Throwable Application Server
Holly Cummins
 
Using Java 8 on Android
Eduardo Felipe Ewert Bonet
 
Its all about the domain honey
Carola Lilienthal
 
Lambdas Hands On Lab
Simon Ritter
 
Lessons Learnt With Lambdas and Streams in JDK 8
Simon Ritter
 
It's Java Jim, But Not As We Know It!
Simon Ritter
 
Embracing Reactive Streams with Java 9 and Spring 5
Wilder Rodrigues
 
Modules in Java? Finally! (OpenJDK 9 Jigsaw, JSR376)
Mihail Stoynov
 
Benefits of OSGi in Practise
David Bosschaert
 
Why OSGi?
bjhargrave
 
I/O Extended (GDG Bogor) - Andrew Kurniadi
Dicoding
 
Java9 and Project Jigsaw
takezoe
 
Project Jigsaw in JDK 9: Modularity Comes To Java
C4Media
 
Ad

Similar to Modularization With Project Jigsaw in JDK 9 (20)

PDF
Voxxed Days Thessaloniki 2016 - JDK 9 : Big Changes To Make Java Smaller
Patroklos Papapetrou (Pat)
 
PDF
Voxxed Days Thessaloniki 2016 - Keynote - JDK 9 : Big Changes To Make Java Sm...
Voxxed Days Thessaloniki
 
PDF
Jigsaw modularity
Srinivasan Raghavan
 
PPTX
Advanced modular development
Srinivasan Raghavan
 
PPTX
Modern Java Workshop
Simon Ritter
 
PPTX
JDK 9: Migrating Applications
Simon Ritter
 
PDF
Serverless Java: JJUG CCC 2019
Shaun Smith
 
PPTX
10 Tips for Java EE 7 with PrimeFaces - JavaOne 2013
Martin Fousek
 
PDF
JDK 10 Java Module System
Wolfgang Weigend
 
PPT
Java8 - Under the hood
Lakshmi Narasimhan
 
PDF
JavaOne 2016: Life after Modularity
DanHeidinga
 
PDF
Modules all the way down: OSGi and the Java Platform Module System
Tim Ellison
 
PDF
Why should i switch to Java SE 7
Vinay H G
 
KEY
Modularization in java 8
pgt technology scouting GmbH
 
PDF
JVMs in Containers - Best Practices
David Delabassee
 
PPTX
JavaOne - 10 Tips for Java EE 7 with PrimeFaces
Mert Çalışkan
 
PDF
Preparing your code for Java 9
Deepu Xavier
 
PDF
Java 9 / Jigsaw - AJUG/VJUG session
Mani Sarkar
 
PDF
Serverless Java - Challenges and Triumphs
David Delabassee
 
PDF
JVMs in Containers
David Delabassee
 
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
 
Jigsaw modularity
Srinivasan Raghavan
 
Advanced modular development
Srinivasan Raghavan
 
Modern Java Workshop
Simon Ritter
 
JDK 9: Migrating Applications
Simon Ritter
 
Serverless Java: JJUG CCC 2019
Shaun Smith
 
10 Tips for Java EE 7 with PrimeFaces - JavaOne 2013
Martin Fousek
 
JDK 10 Java Module System
Wolfgang Weigend
 
Java8 - Under the hood
Lakshmi Narasimhan
 
JavaOne 2016: Life after Modularity
DanHeidinga
 
Modules all the way down: OSGi and the Java Platform Module System
Tim Ellison
 
Why should i switch to Java SE 7
Vinay H G
 
Modularization in java 8
pgt technology scouting GmbH
 
JVMs in Containers - Best Practices
David Delabassee
 
JavaOne - 10 Tips for Java EE 7 with PrimeFaces
Mert Çalışkan
 
Preparing your code for Java 9
Deepu Xavier
 
Java 9 / Jigsaw - AJUG/VJUG session
Mani Sarkar
 
Serverless Java - Challenges and Triumphs
David Delabassee
 
JVMs in Containers
David Delabassee
 

More from Simon Ritter (20)

PPTX
Java Pattern Puzzles Java Pattern Puzzles
Simon Ritter
 
PPTX
Keeping Your Java Hot by Solving the JVM Warmup Problem
Simon Ritter
 
PPTX
Cloud Native Compiler
Simon Ritter
 
PPTX
Java On CRaC
Simon Ritter
 
PPTX
The Art of Java Type Patterns
Simon Ritter
 
PPTX
Modern Java Workshop
Simon Ritter
 
PPTX
Java performance monitoring
Simon Ritter
 
PPTX
Getting the Most From Modern Java
Simon Ritter
 
PPTX
Building a Better JVM
Simon Ritter
 
PPTX
JDK 14 Lots of New Features
Simon Ritter
 
PPTX
Java after 8
Simon Ritter
 
PPTX
How to Choose a JDK
Simon Ritter
 
PPTX
Java Programming
Simon Ritter
 
PPTX
The Latest in Enterprise JavaBeans Technology
Simon Ritter
 
PPTX
Developing Enterprise Applications Using Java Technology
Simon Ritter
 
PPTX
Is Java Still Free?
Simon Ritter
 
PPTX
JDK 9, 10, 11 and Beyond
Simon Ritter
 
PPTX
Java Is Still Free
Simon Ritter
 
PPTX
JDK 9, 10, 11 and Beyond
Simon Ritter
 
PPTX
Java Support: What's changing
Simon Ritter
 
Java Pattern Puzzles Java Pattern Puzzles
Simon Ritter
 
Keeping Your Java Hot by Solving the JVM Warmup Problem
Simon Ritter
 
Cloud Native Compiler
Simon Ritter
 
Java On CRaC
Simon Ritter
 
The Art of Java Type Patterns
Simon Ritter
 
Modern Java Workshop
Simon Ritter
 
Java performance monitoring
Simon Ritter
 
Getting the Most From Modern Java
Simon Ritter
 
Building a Better JVM
Simon Ritter
 
JDK 14 Lots of New Features
Simon Ritter
 
Java after 8
Simon Ritter
 
How to Choose a JDK
Simon Ritter
 
Java Programming
Simon Ritter
 
The Latest in Enterprise JavaBeans Technology
Simon Ritter
 
Developing Enterprise Applications Using Java Technology
Simon Ritter
 
Is Java Still Free?
Simon Ritter
 
JDK 9, 10, 11 and Beyond
Simon Ritter
 
Java Is Still Free
Simon Ritter
 
JDK 9, 10, 11 and Beyond
Simon Ritter
 
Java Support: What's changing
Simon Ritter
 

Recently uploaded (20)

PDF
Exploring AI Agents in Process Industries
amoreira6
 
PPTX
TestNG for Java Testing and Automation testing
ssuser0213cb
 
PDF
The Role of Automation and AI in EHS Management for Data Centers.pdf
TECH EHS Solution
 
PDF
ShowUs: Pharo Stream Deck (ESUG 2025, Gdansk)
ESUG
 
PPT
Why Reliable Server Maintenance Service in New York is Crucial for Your Business
Sam Vohra
 
PDF
Appium Automation Testing Tutorial PDF: Learn Mobile Testing in 7 Days
jamescantor38
 
PPTX
Contractor Management Platform and Software Solution for Compliance
SHEQ Network Limited
 
PPTX
Can You Build Dashboards Using Open Source Visualization Tool.pptx
Varsha Nayak
 
PDF
Key Features to Look for in Arizona App Development Services
Net-Craft.com
 
PDF
49785682629390197565_LRN3014_Migrating_the_Beast.pdf
Abilash868456
 
PDF
QAware_Mario-Leander_Reimer_Architecting and Building a K8s-based AI Platform...
QAware GmbH
 
PPTX
oapresentation.pptx
mehatdhavalrajubhai
 
PDF
Become an Agentblazer Champion Challenge Kickoff
Dele Amefo
 
PDF
Micromaid: A simple Mermaid-like chart generator for Pharo
ESUG
 
PDF
Become an Agentblazer Champion Challenge
Dele Amefo
 
PDF
IEEE-CS Tech Predictions, SWEBOK and Quantum Software: Towards Q-SWEBOK
Hironori Washizaki
 
PDF
Teaching Reproducibility and Embracing Variability: From Floating-Point Exper...
University of Rennes, INSA Rennes, Inria/IRISA, CNRS
 
PDF
What to consider before purchasing Microsoft 365 Business Premium_PDF.pdf
Q-Advise
 
PDF
Why Use Open Source Reporting Tools for Business Intelligence.pdf
Varsha Nayak
 
PPTX
Explanation about Structures in C language.pptx
Veeral Rathod
 
Exploring AI Agents in Process Industries
amoreira6
 
TestNG for Java Testing and Automation testing
ssuser0213cb
 
The Role of Automation and AI in EHS Management for Data Centers.pdf
TECH EHS Solution
 
ShowUs: Pharo Stream Deck (ESUG 2025, Gdansk)
ESUG
 
Why Reliable Server Maintenance Service in New York is Crucial for Your Business
Sam Vohra
 
Appium Automation Testing Tutorial PDF: Learn Mobile Testing in 7 Days
jamescantor38
 
Contractor Management Platform and Software Solution for Compliance
SHEQ Network Limited
 
Can You Build Dashboards Using Open Source Visualization Tool.pptx
Varsha Nayak
 
Key Features to Look for in Arizona App Development Services
Net-Craft.com
 
49785682629390197565_LRN3014_Migrating_the_Beast.pdf
Abilash868456
 
QAware_Mario-Leander_Reimer_Architecting and Building a K8s-based AI Platform...
QAware GmbH
 
oapresentation.pptx
mehatdhavalrajubhai
 
Become an Agentblazer Champion Challenge Kickoff
Dele Amefo
 
Micromaid: A simple Mermaid-like chart generator for Pharo
ESUG
 
Become an Agentblazer Champion Challenge
Dele Amefo
 
IEEE-CS Tech Predictions, SWEBOK and Quantum Software: Towards Q-SWEBOK
Hironori Washizaki
 
Teaching Reproducibility and Embracing Variability: From Floating-Point Exper...
University of Rennes, INSA Rennes, Inria/IRISA, CNRS
 
What to consider before purchasing Microsoft 365 Business Premium_PDF.pdf
Q-Advise
 
Why Use Open Source Reporting Tools for Business Intelligence.pdf
Varsha Nayak
 
Explanation about Structures in C language.pptx
Veeral Rathod
 

Modularization With Project Jigsaw in JDK 9

  • 1. © Copyright Azul Systems 2016 © Copyright Azul Systems 2015 @speakjava Modularization with Project Jigsaw in JDK 9 Simon Ritter Deputy CTO, Azul Systems 1
  • 2. © Copyright Azul Systems 2016 Agenda  JDK 9 API structure overview  Introduction to Jigsaw and modules  Developing code with modules  Summary and further information 2
  • 3. © Copyright Azul Systems 2016 JDK 9 API Structure Overview 3
  • 4. © 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  See how long you can keep a project going for 4
  • 5. © 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 5
  • 6. © 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 6
  • 7. © 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  Change the binary structure of the JRE and JDK  Remove the endorsed-standards override and extension mechanism  New version string format  A single underscore will no longer be allowed as an identifier in source code 7
  • 8. © Copyright Azul Systems 2016 Most Popular Unsupported APIs 1. sun.misc.BASE64Encoder 2. sun.misc.Unsafe 3. sun.misc.BASE64Decoder 8 Oracle dataset based on internal application code
  • 9. © 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 9
  • 10. © Copyright Azul Systems 2016 JEP 260 Proposal 1. Encapsulate all non-critical JDK-internal APIs 2. Encapsulate all critical JDK-internal APIs, for which supported replacements exist in JDK 8 3. 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 10
  • 11. © 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 11
  • 12. © 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
  • 13. © Copyright Azul Systems 2016 Introduction to Jigsaw and Modules 13
  • 14. © 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 14 com.azul.zoop com.azul.zoop.alpha.Name com.azul.zoop.alpha.Position com.azul.zoop.beta.Animal com.azul.zoop.beta.Zoo
  • 15. © Copyright Azul Systems 2016 Module Declaration 15 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
  • 16. © Copyright Azul Systems 2016 Module Dependencies module com.azul.zoop { requires com.azul.zeta; } com.azul.zoop com.azul.zeta
  • 17. © 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
  • 18. © Copyright Azul Systems 2016 Module Dependency Graph com.azul.app java.base java.sqlcom.azul.zoop com.azul.zeta java.xml java.logging
  • 19. © 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
  • 20. © 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
  • 21. © 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’);
  • 22. © Copyright Azul Systems 2016 Module Readability Graph com.azul.app java.base java.sqlcom.azul.zoop com.azul.zeta java.xml java.logging
  • 23. © Copyright Azul Systems 2016 Java Accessibility (pre-JDK 9) public protected <package> private
  • 24. © 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)
  • 25. © Copyright Azul Systems 2016 JDK Platform Modules 25
  • 26. © Copyright Azul Systems 2016 Developing Code With Modules 26
  • 27. © Copyright Azul Systems 2016 Compilation 27 $ javac –d mods src/zeta/module-info.java src/zeta/com/azul/zeta/Vehicle.java mods/zeta/mod-info.class mods/zeta/com/azul/zeta/Vehicle.class src/zeta/mod-info.java src/zeta/com/azul/zeta/Vehicle.java
  • 28. © Copyright Azul Systems 2016 Module Path $ javac –modulepath dir1:dir2:dir3
  • 29. © Copyright Azul Systems 2016 Compilation With Module Path 29 $ javac –modulepath mlib –d mods src/zoop/module-info.java src/zoop/com/azul/zoop/alpha/Name.java mods/zoop/mod-info.class mods/zoop/com/azul/zoop/alpha/Name.class src/zoop/mod-info.java src/zoop/com/azul/zoop/alpha/Name.java
  • 30. © Copyright Azul Systems 2016 Application Execution  -modulepath can be abbreviated to -mp $ java –modulepath mods –m com.azul.app/com.azul.app.Main Azul application initialised! module name main class
  • 31. © Copyright Azul Systems 2016 Packaging With Modular Jars mods/app/mod-info.class mods/app/com/azul/app/Main.class $ jar --create --file mlib/app.jar --main-class com.azul.app.Main -C mods . module-info.class com/azul/zoop/Main.class app.jar
  • 32. © Copyright Azul Systems 2016 Jar Files & Module Information $ jar --file mlib/app.jar –p Name: com.azul.app Requires: com.azul.zoop java.base [MANDATED] java.sql Main class: com.azul.app.Main
  • 33. © Copyright Azul Systems 2016 Application Execution (JAR) $ java –mp mlib:mods –m com.azul.app.Main Azul application initialised!
  • 34. © Copyright Azul Systems 2016 Linking Modular run-time image …confbin jlink $ jlink --modulepath $JDKMODS --addmods java.base –output myimage $ myimage/bin/java –listmods [email protected]
  • 35. © Copyright Azul Systems 2016 Linking An Application $ jlink --modulepath $JDKMODS:$MYMODS --addmods com.azul.app –output myimage $ myimage/bin/java –listmods [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected]
  • 36. © Copyright Azul Systems 2016 Summary & Further Information 36
  • 37. © Copyright Azul Systems 2016 Summary  Modularisation is a big change for Java – JVM/JRE rather than language/APIs – Public access isn’t necessarily the same  Flexibility to define what is exported  New linking capability to generate runtime image  More to learn about converting existing code  Will make all applications simpler to deploy and manage 37
  • 38. © Copyright Azul Systems 2016 Further Information  openjdk.java.net  openjdk.java.net/jeps – 200, 201, 220, 260, 261  openjdk.java.net/projects/jigsaw  jcp.org – JSR 376  www.zulu.org (OpenJDK supported builds JDK 6, 7, 8, 9)  www.azul.com (Zing JVM for low latency) 38
  • 39. © Copyright Azul Systems 2016 © Copyright Azul Systems 2015 @speakjava Modularization with Project Jigsaw in JDK 9 Simon Ritter Deputy CTO, Azul Systems 39

Editor's Notes

  • #6: com.sun API examples mostly around tooling jdk API example is nashorn
  • #8: 6 APIs are in LogManager and Pack200