SlideShare a Scribd company logo
Java 9
That's one small step for a man, one giant leap for mankind.
Neil Amstrong
Open, Modular, Small
(Açık, Modüler, Küçük)
Who am I?

Married and father of twins.

Graduated from Marmara University CSE in 2002.

Worked 12,5 years at Oksijen in the roles of "Software
Developer", "Software Architect", "Team Leader", "Technical
Coordinator" and "Mentor".

Currently working in IBTech as a "Software Architect".

Developed various applications in different sizes from small
libraries/tools to distributed/telco-grade/backend java
applications.Expert in understanding and beautifying
someone else's code (Refactoring & Clean Coding).
/in/hasanunal
/hasanunalcom
Oracle Java History

JDK 1.0 (Jan 1996)

JDK 1.1 (Feb 1997)

J2SE 1.2 (Dec 1998)

J2SE 1.3 (May 2000)

J2SE 1.4 (Feb 2002)

J2SE 5.0 (Sep 2004)

Java SE 6 (Dec 2006)
-------- Sun open sources JDK (Mar 2007)
-------- Oracle acquires Sun (Apr 2009)

Java SE 7 (Jul 2011)

Java SE 8 (Mar 2014)

Java 9 (Sep 2017)
Notable Dates
Release - Early 2016 Delayed
Release - September 2016 Delayed
Release - 23 March 2017 Delayed
8 May 2017 EC rejected the JPMS spec.
Release - 21 July 2017 Delayed
Release - 21 September 2017 Released
Final Ballot
JCP? JSR? EC? EG? JEP?
IBM Java 9!

IBM Java Distros
– AIX (OS)
– Linux on Power System (server)
– Linux on z Systems (mainframe)
– z/OS on z Systems (mainframe)
– Windows (for development)

IBM Java 9 beta

Join IBM Open Beta Program
https://developer.ibm.com/javasdk/2017/02/08/our-java-9-beta-is-open-for-business/
Java News

OracleJDK is merged with OpenJDK and Oracle distributes
OpenJDK as from Java9.

Commercial features will be in OpenJDK.

Release Cadance: 6 months.

Java 10: http://openjdk.java.net/projects/jdk10/ (Mar 2018)

Oracle leaves
– JEE to Eclipse community
– Netbeans to Apache community

IBM open sources it's own jvm (J9).
Java 10
Main Features of Java 9
91 JEPs are implemented. (link)

JDK

Module System (JPMS)

Versioning Schema

Tools

+Multi-Release JAR Files

+Compile for Older Versions

+jshell (repl) +jlink +jmod

-hprof -jhat

~javac ~java ~jcmd

Security

-SHA-1

+SHA-3
Main Features of Java 9

Deployment

Deprecate Java Plugin (Applet)

jlink

Language

@SafeVargs

Try-with-resources

Diamond w/ anonymous classes

Identifier name Underscore (_) removal

Private interface methods.

Javadoc

HTML5 output

Javadoc search

Module System support
Main Features of Java 9

Core Libraries

Process API Updates

Variable Handles

Compact Strings

Platform Logging API and Service

More Concurrency Updates

Factory Methods for Collections

Enhanced Method Handles

Enhanced Deprecation

Spin-Wait Hints

Filter Incoming Serialization Data

Stack-Walking API
Main Features of Java 9

JVM

Compiler control

Segmented Code Cache (for native code)

JVM Tuning

Unified JVM/GC Logging

Remove GC Combinations Deprecated in JDK 8

Make G1 the Default Garbage Collector

Deprecate the CMS GC

Internationalization

Unicode 8.0

UTF-8 properties

Installer
Main Features of Java 9

Client

TIFF Image I/O

Multi-Resolution Images

JavaFX module system support

BeanInfo annotations

HiDPI Graphics on Windows and Linux

Platform-Specific Desktop Features

Nashorn (JS Engine)

Parser API for Nashorn

Implement Selected ECMAScript 6 Features in Nashorn
− Template strings
− let, const, and block scope
− Iterators and for..of loops
− Map, Set, WeakMap, and WeakSet
− Symbols
− Binary and octal literals
JPMS – Module System
WHY

Make the Java SE Platform/JDK, more easily
scalable down to small computing devices

Improve the security and maintainability of
Java SE Platform Implementations in general,
and the JDK in particular

Enable improved application performance

Make it easier for developers to construct and
maintain libraries and large applications,
for both the Java SE and EE Platforms.
JPMS – Module System
THUS

Strong encapsulation (among modules)

Better architectural design

Improve security

Reliable configuration

Introduce dependency management (sort of)

Space efficiency & performance
JPMS – Module Definition
A module is a named, self-describing collection of code and data.
And contains packages (classes & interfaces),
resources, other static information (e.g. META-INF)
module modul.demo.a {} // depends on java.base
module modul.demo.bank {
exports modul.demo.bank;
}
module modul.demo.bank.client {
requires modul.demo.bank;
}
JPMS – Module Definition
Directory Structure
ModulDemo2BankClient/ → Eclipse project base
src/ → Source folder
modul.demo.bank.client/ → module source folder
module-info.java → module descriptor
modul/demo/bank/client/ → package
BankClient.java → java Class
Jar Structure (1 jar = 1 module)
META-INF/
META-INF/MANIFEST.MF
module-info.class
modul/demo/bank/client/BankClient.class
JPMS – Platform Modules
Java Platform is divided into modules.
https://blog.codecentric.de/files/2015/11/jdk-tr1.png
JPMS – Platform Modules
Base Module (“java.base”)

Always present

Only module known by module system

Exports all of the platform's core packages

Every other module depends implicitly upon base module

Base module depends upon no other module
module java.base {
exports java.io;
exports java.lang;
exports java.lang.invoke;
exports java.lang.module;
exports java.lang.ref;
exports java.lang.reflect;
exports java.net;
...
}
JPMS – Using Modules
Module Path

Means to locate whole modules (similar to classpath)

Resolves module dependences

System path contains module artifacts (jars) or
module directories
e.g. %JAVA_HOME%/jmods;libs

If the module system is unable to find a dependent module
or if it encounters two modules w/ same name
then the compiler or virtual machine report an error and exits
JPMS – Module Resolution
module com.my.pkg {
requires org.apaçi.lib;
}
module com.my.app {
requires com.my.pkg;
requires java.sql;
}
module org.apaçi.lib {
}
Resolution Start Here:
Initial Application Module
MODULE
GRAPH
Explicit dependence
vs
Implicit dependence
module java.sql {
requires java.logging;
requires java.xml;
exports java.sql;
exports javax.sql;
exports javax.transaction.xa;
}
JPMS – Implied Readibility
// Application Code
Driver d = DriverManager.getDriver(url); java.sql→
Connection c = d.connect(url, props); java.sql→
d.getParentLogger().info("Connection acquired"); java.logging→
How can the application access “java.logging” module?
Revise “java.sql” module descriptor
module java.sql {
requires public java.logging;
requires public java.xml;
exports java.sql;
exports javax.sql;
exports javax.transaction.xa;
}
If one module exports a package containing a type whose signature refers to a package
in a second module then the declaration of the first module should include a requires
public dependence upon the second.
JPMS – Unnamed Module

All jars loaded from the classpath are considered
as a member of Unnamed Module.

Ensures that every type is associated with a module.

The unnamed module reads every other module
(i.e. all named & built-in platform modules)
Thus existing Java 8 application compile and run on Java 9.
(unless api's are deprecated or removed)

The unnamed module exports all of its packages.
But named module can not access types in the unnamed module.

If a package is defined in both a named module and the unnamed
module then the package in the unnamed module is ignored.
JPMS – Unnamed Module
If our application is written before Java 8, module dependences
in Java 9 is as below:
Grey covered jars are in classpath, therefore they are defined
as “unnamed module”.
JPMS – Bottom-Up Migration
What to migrate to Java 9?
Find the intermodule dependencies (using jdeps)
Use buttom-up approach to select&migrate to modules.
com-foo-app.jar
com-foo-bar.jar
org-baz-qux.jar
It is easy to migrate “org.baz.qux” to module system.
Because it has no dependences.
JPMS – Bottom-Up Migration
Continue to bottom-up migration
What if “org.baz.qux.jar” is maintained by another organization and
cannot be converted to a named module?
Is it possible to migrate other jars into modules?
JPMS – Automatic Module

A jar w/o module descriptor in modulepath is defined as
automatic module

Accesses all other modules (named and unnamed)

Implicitly exports all of its packages to Unnamed Module

Can be read explicitly by named modules.

Mudule name is automatically determined using jar name
(subject to change)

Removes the file extension

Removes trailing version number

replaces all the non-alphanumeric characters with dots
mysql-connector-java-6.1.6.jar → mysql.connector.java
JPMS – Top-Down Migration
− Application jars are not module.
− JRE is Java9. Therefore, platform (java.*) modules exists
in environment.
− Want to convert application jars into modules.

Only com-foo-app.jar and com-foo-bar.jar can be converted.

org-baz-qux.jar is maintained by another organization.
com-foo-app.jar
com-foo-bar.jar
org-baz-qux.jar
Current Situation
JPMS – Top-Down Migration
module com.foo.bar {
requires org.baz.qux;
}
module com.foo.app {
requires com.foo.bar;
requires java.sql;
}

Move org-baz-qux.jar to module-path. It will have
automodule name: org-baz-qux.jar → org.baz.qux

Now com-foo-app.jar and com-foo-bar.jar can
depend upon org.baz.qux module.
org.baz.qux
→ Automatic Module
JPMS – Top-Down Migration
Notes

Automatic Modules allow an existing application to be migrated
to modules from the top down (first app.jar then other jars)

To migrate the jars in classpath

Find and analyze interdependency (jdeps)

Convert the source code of your organization into modules

Move 3rd
party jars into module-path to make them
automodule
thus, your module code may depend/read the automodules.
(until module versions of 3rd
party jars are prepared)
JPMS – Module Types Summary
MODULE TYPE MODULE DESCRIPTOR LOCATION
Application Module Exists Module-path
Automatic Module Doesn't exist Module-path
Unnamed Module Exists or Doesn't exist Class-path
Platform Module Exists Platform's Module-path
MODULE TYPE EXPORTS
PACKAGES
CAN READ
MODULES
CAN BE READ BY
MODULES
Application Module Explicitly Application
Platform
Automatic
Application
Automatic
Unnamed
Platform Module Explicitly Platform All types of modules
Unnamed Module All All types of modules Application
Automatic
Unnamed
Automatic Module All All types of modules Application
Automatic
Unnamed
JPMS – Readability Summary
JPMS – Service Loader

Provides loose-coupling among modules.

Based on the java.util.ServiceLoader mechanism.

Service Loader locates the service providers at run-time
by searching jars in classpath.
JPMS – Service Loader
Service Loader in Java 7
Service File:
META-INF
/services
/com.example.CodecSet
File Content:
com.example.impl.StandardCodecs # Standard codecs
Code:
Iterator<CodecSet> codecs =
ServiceLoader.load(CodecSet.class).iterator();
foreach(codec) {
//select codec instance.
}
JPMS – Services
module java.sql {
requires public java.logging;
requires public java.xml;
exports java.sql;
exports javax.sql;
exports javax.transaction.xa;
uses java.sql.Driver;
}
module com.mysql.jdbc {
requires java.sql;
requires org.slf4j;
exports com.mysql.jdbc;
provides java.sql.Driver
with com.mysql.jdbc.Driver;
}
JPMS – Services
Highligts
Declaring service relation in module declaration

Improves efficiency and clarity (locating/loading time)

Provides compile&run time accessibility check

Provides compile-time type compatibility check

Provides safe linking prior to run-time

Provides capability to run Ahead-of-Time Compilation
JPMS – Reflection
package java.lang.reflect;
public final class Module {
public String getName();
public ModuleDescriptor getDescriptor();
public ClassLoader getClassLoader();
public boolean canRead(Module target);
public boolean isExported(String packageName);
}

Every Class object has an associated Module object

Module object returns by the Class::getModule method

ModuleDescriptor class represents module descriptor

canRead() tells whether the module can read the target module

isExported() tells whether the module exports given package

Class.forName() continues to work as soon as the reflected class
is exported in target module and readable by caller module.
JPMS – Class Loader

Modules names/packages don't have to interfere with each other

A module has to be loaded/associated by only one class loader

Exception: Unnamed Module is associated by all class loaders.

Existing Hierarchy is
preserved.

Bootstrap and extension
class loaders load platform
modules.

Application class loader
loads classes of modules in
the module path.

Load classes from one or
more modules.

Besides application modules, new layer may contain upgradable
platform modules as soon as they are loaded from a different location.

During resolution process, modules in new layer can read modules in
lower layers.
CONTAINER
JPMS – Layers
Upgradeable modules
v1.0v1.1

Container launches the
application w/ initial layer (L1)

An upgrade necessitates and
v1.1 modules are loaded in a
new layer (L2) on the top of
initial layer (L1) from a
different jar location.

Container performs this loading
operation by using module
reflection API's and dynamic
class loading.
JPMS – Qualified Exports

Allows a package to be exported to specifically-named modules.
module java.base {
...
exports sun.reflect to
java.corba,
java.logging,
java.sql,
java.sql.rowset,
jdk.scripting.nashorn;
}

Can be used to hide the internal implementation from the
unintended users.

Provides a kind of module security. (e.g. in container environment)
Resources
http://openjdk.java.net/projects/jigsaw/spec/sotms/
TTTTTTTTTTTTTTTTTTTTTTTHHHHHHHHH HHHHHHHHH AAA NNNNNNNN NNNNNNNNKKKKKKKKK KKKKKKK
T:::::::::::::::::::::TH:::::::H H:::::::H A:::A N:::::::N N::::::NK:::::::K K:::::K
T:::::::::::::::::::::TH:::::::H H:::::::H A:::::A N::::::::N N::::::NK:::::::K K:::::K
T:::::TT:::::::TT:::::THH::::::H H::::::HH A:::::::A N:::::::::N N::::::NK:::::::K K::::::K
TTTTTT T:::::T TTTTTT H:::::H H:::::H A:::::::::A N::::::::::N N::::::NKK::::::K K:::::KKK
T:::::T H:::::H H:::::H A:::::A:::::A N:::::::::::N N::::::N K:::::K K:::::K
T:::::T H::::::HHHHH::::::H A:::::A A:::::A N:::::::N::::N N::::::N K::::::K:::::K
T:::::T H:::::::::::::::::H A:::::A A:::::A N::::::N N::::N N::::::N K:::::::::::K
T:::::T H:::::::::::::::::H A:::::A A:::::A N::::::N N::::N:::::::N K:::::::::::K
T:::::T H::::::HHHHH::::::H A:::::AAAAAAAAA:::::A N::::::N N:::::::::::N K::::::K:::::K
T:::::T H:::::H H:::::H A:::::::::::::::::::::A N::::::N N::::::::::N K:::::K K:::::K
T:::::T H:::::H H:::::H A:::::AAAAAAAAAAAAA:::::A N::::::N N:::::::::NKK::::::K K:::::KKK
TT:::::::TT HH::::::H H::::::HH A:::::A A:::::A N::::::N N::::::::NK:::::::K K::::::K
T:::::::::T H:::::::H H:::::::H A:::::A A:::::A N::::::N N:::::::NK:::::::K K:::::K
T:::::::::T H:::::::H H:::::::H A:::::A A:::::A N::::::N N::::::NK:::::::K K:::::K
TTTTTTTTTTT HHHHHHHHH HHHHHHHHHAAAAAAA AAAAAAANNNNNNNN NNNNNNNKKKKKKKKK KKKKKKK
YYYYYYY YYYYYYY OOOOOOOOO UUUUUUUU UUUUUUUU
Y:::::Y Y:::::Y OO:::::::::OO U::::::U U::::::U
Y:::::Y Y:::::Y OO:::::::::::::OO U::::::U U::::::U
Y::::::Y Y::::::YO:::::::OOO:::::::OUU:::::U U:::::UU
YYY:::::Y Y:::::YYYO::::::O O::::::O U:::::U U:::::U
Y:::::Y Y:::::Y O:::::O O:::::O U:::::D D:::::U
Y:::::Y:::::Y O:::::O O:::::O U:::::D D:::::U
Y:::::::::Y O:::::O O:::::O U:::::D D:::::U
Y:::::::Y O:::::O O:::::O U:::::D D:::::U
Y:::::Y O:::::O O:::::O U:::::D D:::::U
Y:::::Y O:::::O O:::::O U:::::D D:::::U
Y:::::Y O::::::O O::::::O U::::::U U::::::U
Y:::::Y O:::::::OOO:::::::O U:::::::UUU:::::::U
YYYY:::::YYYY OO:::::::::::::OO UU:::::::::::::UU
Y:::::::::::Y OO:::::::::OO UU:::::::::UU
YYYYYYYYYYYYY OOOOOOOOO UUUUUUUUU

More Related Content

What's hot (20)

PPT
11 constructors in derived classes
Docent Education
 
PPT
16 virtual function
Docent Education
 
PDF
Object-oriented Programming-with C#
Doncho Minkov
 
PPTX
Bluej
Saurabh Bhartiya
 
PDF
Data Persistence in Android with Room Library
Reinvently
 
PPT
Angular Introduction By Surekha Gadkari
Surekha Gadkari
 
PPT
Angular 8
Sunil OS
 
PPTX
Introduction to Maven
Onkar Deshpande
 
PPTX
Fitness App ppt
Azmeen Gadit
 
PPT
Introduction To C#
SAMIR BHOGAYTA
 
PPTX
Spring framework IOC and Dependency Injection
Anuj Singh Rajput
 
PPTX
Saving Time By Testing With Jest
Ben McCormick
 
PDF
Spring boot introduction
Rasheed Waraich
 
PPT
Core java concepts
Ram132
 
PDF
Support de cours technologie et application m.youssfi
ENSET, Université Hassan II Casablanca
 
PPTX
The Single Responsibility Principle
Lars-Erik Kindblad
 
PDF
Module 3 remote method invocation-2
Ankit Dubey
 
PPTX
Spring boot
Pradeep Shanmugam
 
PPTX
Webinar - Desarrollo con Oracle Application Express (APEX): demostración prác...
avanttic Consultoría Tecnológica
 
PPT
Day 4: Android: UI Widgets
Ahsanul Karim
 
11 constructors in derived classes
Docent Education
 
16 virtual function
Docent Education
 
Object-oriented Programming-with C#
Doncho Minkov
 
Data Persistence in Android with Room Library
Reinvently
 
Angular Introduction By Surekha Gadkari
Surekha Gadkari
 
Angular 8
Sunil OS
 
Introduction to Maven
Onkar Deshpande
 
Fitness App ppt
Azmeen Gadit
 
Introduction To C#
SAMIR BHOGAYTA
 
Spring framework IOC and Dependency Injection
Anuj Singh Rajput
 
Saving Time By Testing With Jest
Ben McCormick
 
Spring boot introduction
Rasheed Waraich
 
Core java concepts
Ram132
 
Support de cours technologie et application m.youssfi
ENSET, Université Hassan II Casablanca
 
The Single Responsibility Principle
Lars-Erik Kindblad
 
Module 3 remote method invocation-2
Ankit Dubey
 
Spring boot
Pradeep Shanmugam
 
Webinar - Desarrollo con Oracle Application Express (APEX): demostración prác...
avanttic Consultoría Tecnológica
 
Day 4: Android: UI Widgets
Ahsanul Karim
 

Similar to Java 9 Module System (20)

PDF
Java 9 / Jigsaw - AJUG/VJUG session
Mani Sarkar
 
PDF
Modules all the way down: OSGi and the Java Platform Module System
Tim Ellison
 
PPT
Java8 - Under the hood
Lakshmi Narasimhan
 
PPTX
java basic for begginers
divaskrgupta007
 
PPTX
Manuel - SPR - Intro to Java Language_2016
Manuel Fomitescu
 
PPTX
Java Platform Module System
Vignesh Ramesh
 
PPTX
Java 9 Modularity and Project Jigsaw
Comsysto Reply GmbH
 
PPTX
OOP with Java
OmegaHub
 
PDF
Java 9 / Jigsaw - LJC / VJUG session (hackday session)
Mani Sarkar
 
PPTX
What's New in Java 9
Richard Langlois P. Eng.
 
PPTX
Unit 1 – Introduction to Java- (Shilpa R).pptx
shilpar780389
 
PPTX
Apache Maven supports all Java (JokerConf 2018)
Robert Scholte
 
PPT
Jddk
tatoriver
 
PPTX
Java 9
Netesh Kumar
 
PPTX
Apache Maven supports ALL Java (Javaland 2019)
Robert Scholte
 
PPTX
Presentation5
Natasha Bains
 
PPTX
Java 9: Deep Dive into Modularity and Dealing with Migration Issues
GlobalLogic Ukraine
 
PPTX
Preparing for java 9 modules upload
Ryan Cuprak
 
PPT
Object Oriented Programming-JAVA
Home
 
Java 9 / Jigsaw - AJUG/VJUG session
Mani Sarkar
 
Modules all the way down: OSGi and the Java Platform Module System
Tim Ellison
 
Java8 - Under the hood
Lakshmi Narasimhan
 
java basic for begginers
divaskrgupta007
 
Manuel - SPR - Intro to Java Language_2016
Manuel Fomitescu
 
Java Platform Module System
Vignesh Ramesh
 
Java 9 Modularity and Project Jigsaw
Comsysto Reply GmbH
 
OOP with Java
OmegaHub
 
Java 9 / Jigsaw - LJC / VJUG session (hackday session)
Mani Sarkar
 
What's New in Java 9
Richard Langlois P. Eng.
 
Unit 1 – Introduction to Java- (Shilpa R).pptx
shilpar780389
 
Apache Maven supports all Java (JokerConf 2018)
Robert Scholte
 
Jddk
tatoriver
 
Java 9
Netesh Kumar
 
Apache Maven supports ALL Java (Javaland 2019)
Robert Scholte
 
Presentation5
Natasha Bains
 
Java 9: Deep Dive into Modularity and Dealing with Migration Issues
GlobalLogic Ukraine
 
Preparing for java 9 modules upload
Ryan Cuprak
 
Object Oriented Programming-JAVA
Home
 
Ad

Recently uploaded (20)

PDF
>Wondershare Filmora Crack Free Download 2025
utfefguu
 
PPTX
Iobit Driver Booster Pro 12 Crack Free Download
chaudhryakashoo065
 
PDF
WholeClear Split vCard Software for Split large vCard file
markwillsonmw004
 
PPTX
CV-Project_2024 version 01222222222.pptx
MohammadSiddiqui70
 
PPTX
For my supp to finally picking supp that work
necas19388
 
PPTX
ERP - FICO Presentation BY BSL BOKARO STEEL LIMITED.pptx
ravisranjan
 
PDF
TEASMA: A Practical Methodology for Test Adequacy Assessment of Deep Neural N...
Lionel Briand
 
PPTX
NeuroStrata: Harnessing Neuro-Symbolic Paradigms for Improved Testability and...
Ivan Ruchkin
 
PDF
From Chaos to Clarity: Mastering Analytics Governance in the Modern Enterprise
Wiiisdom
 
PPTX
IObit Driver Booster Pro Crack Download Latest Version
chaudhryakashoo065
 
PDF
The Rise of Sustainable Mobile App Solutions by New York Development Firms
ostechnologies16
 
PDF
Difference Between Kubernetes and Docker .pdf
Kindlebit Solutions
 
PDF
Power BI vs Tableau vs Looker - Which BI Tool is Right for You?
MagnusMinds IT Solution LLP
 
PDF
Writing Maintainable Playwright Tests with Ease
Shubham Joshi
 
PDF
Code Once; Run Everywhere - A Beginner’s Journey with React Native
Hasitha Walpola
 
PPTX
Introduction to web development | MERN Stack
JosephLiyon
 
PPTX
Seamless-Image-Conversion-From-Raster-to-wrt-rtx-rtx.pptx
Quick Conversion Services
 
PDF
capitulando la keynote de GrafanaCON 2025 - Madrid
Imma Valls Bernaus
 
PDF
LPS25 - Operationalizing MLOps in GEP - Terradue.pdf
terradue
 
PPTX
How Can Recruitment Management Software Improve Hiring Efficiency?
HireME
 
>Wondershare Filmora Crack Free Download 2025
utfefguu
 
Iobit Driver Booster Pro 12 Crack Free Download
chaudhryakashoo065
 
WholeClear Split vCard Software for Split large vCard file
markwillsonmw004
 
CV-Project_2024 version 01222222222.pptx
MohammadSiddiqui70
 
For my supp to finally picking supp that work
necas19388
 
ERP - FICO Presentation BY BSL BOKARO STEEL LIMITED.pptx
ravisranjan
 
TEASMA: A Practical Methodology for Test Adequacy Assessment of Deep Neural N...
Lionel Briand
 
NeuroStrata: Harnessing Neuro-Symbolic Paradigms for Improved Testability and...
Ivan Ruchkin
 
From Chaos to Clarity: Mastering Analytics Governance in the Modern Enterprise
Wiiisdom
 
IObit Driver Booster Pro Crack Download Latest Version
chaudhryakashoo065
 
The Rise of Sustainable Mobile App Solutions by New York Development Firms
ostechnologies16
 
Difference Between Kubernetes and Docker .pdf
Kindlebit Solutions
 
Power BI vs Tableau vs Looker - Which BI Tool is Right for You?
MagnusMinds IT Solution LLP
 
Writing Maintainable Playwright Tests with Ease
Shubham Joshi
 
Code Once; Run Everywhere - A Beginner’s Journey with React Native
Hasitha Walpola
 
Introduction to web development | MERN Stack
JosephLiyon
 
Seamless-Image-Conversion-From-Raster-to-wrt-rtx-rtx.pptx
Quick Conversion Services
 
capitulando la keynote de GrafanaCON 2025 - Madrid
Imma Valls Bernaus
 
LPS25 - Operationalizing MLOps in GEP - Terradue.pdf
terradue
 
How Can Recruitment Management Software Improve Hiring Efficiency?
HireME
 
Ad

Java 9 Module System

  • 1. Java 9 That's one small step for a man, one giant leap for mankind. Neil Amstrong Open, Modular, Small (Açık, Modüler, Küçük)
  • 2. Who am I?  Married and father of twins.  Graduated from Marmara University CSE in 2002.  Worked 12,5 years at Oksijen in the roles of "Software Developer", "Software Architect", "Team Leader", "Technical Coordinator" and "Mentor".  Currently working in IBTech as a "Software Architect".  Developed various applications in different sizes from small libraries/tools to distributed/telco-grade/backend java applications.Expert in understanding and beautifying someone else's code (Refactoring & Clean Coding). /in/hasanunal /hasanunalcom
  • 3. Oracle Java History  JDK 1.0 (Jan 1996)  JDK 1.1 (Feb 1997)  J2SE 1.2 (Dec 1998)  J2SE 1.3 (May 2000)  J2SE 1.4 (Feb 2002)  J2SE 5.0 (Sep 2004)  Java SE 6 (Dec 2006) -------- Sun open sources JDK (Mar 2007) -------- Oracle acquires Sun (Apr 2009)  Java SE 7 (Jul 2011)  Java SE 8 (Mar 2014)  Java 9 (Sep 2017)
  • 4. Notable Dates Release - Early 2016 Delayed Release - September 2016 Delayed Release - 23 March 2017 Delayed 8 May 2017 EC rejected the JPMS spec. Release - 21 July 2017 Delayed Release - 21 September 2017 Released
  • 5. Final Ballot JCP? JSR? EC? EG? JEP?
  • 6. IBM Java 9!  IBM Java Distros – AIX (OS) – Linux on Power System (server) – Linux on z Systems (mainframe) – z/OS on z Systems (mainframe) – Windows (for development)  IBM Java 9 beta  Join IBM Open Beta Program https://developer.ibm.com/javasdk/2017/02/08/our-java-9-beta-is-open-for-business/
  • 7. Java News  OracleJDK is merged with OpenJDK and Oracle distributes OpenJDK as from Java9.  Commercial features will be in OpenJDK.  Release Cadance: 6 months.  Java 10: http://openjdk.java.net/projects/jdk10/ (Mar 2018)  Oracle leaves – JEE to Eclipse community – Netbeans to Apache community  IBM open sources it's own jvm (J9).
  • 9. Main Features of Java 9 91 JEPs are implemented. (link)  JDK  Module System (JPMS)  Versioning Schema  Tools  +Multi-Release JAR Files  +Compile for Older Versions  +jshell (repl) +jlink +jmod  -hprof -jhat  ~javac ~java ~jcmd  Security  -SHA-1  +SHA-3
  • 10. Main Features of Java 9  Deployment  Deprecate Java Plugin (Applet)  jlink  Language  @SafeVargs  Try-with-resources  Diamond w/ anonymous classes  Identifier name Underscore (_) removal  Private interface methods.  Javadoc  HTML5 output  Javadoc search  Module System support
  • 11. Main Features of Java 9  Core Libraries  Process API Updates  Variable Handles  Compact Strings  Platform Logging API and Service  More Concurrency Updates  Factory Methods for Collections  Enhanced Method Handles  Enhanced Deprecation  Spin-Wait Hints  Filter Incoming Serialization Data  Stack-Walking API
  • 12. Main Features of Java 9  JVM  Compiler control  Segmented Code Cache (for native code)  JVM Tuning  Unified JVM/GC Logging  Remove GC Combinations Deprecated in JDK 8  Make G1 the Default Garbage Collector  Deprecate the CMS GC  Internationalization  Unicode 8.0  UTF-8 properties  Installer
  • 13. Main Features of Java 9  Client  TIFF Image I/O  Multi-Resolution Images  JavaFX module system support  BeanInfo annotations  HiDPI Graphics on Windows and Linux  Platform-Specific Desktop Features  Nashorn (JS Engine)  Parser API for Nashorn  Implement Selected ECMAScript 6 Features in Nashorn − Template strings − let, const, and block scope − Iterators and for..of loops − Map, Set, WeakMap, and WeakSet − Symbols − Binary and octal literals
  • 14. JPMS – Module System WHY  Make the Java SE Platform/JDK, more easily scalable down to small computing devices  Improve the security and maintainability of Java SE Platform Implementations in general, and the JDK in particular  Enable improved application performance  Make it easier for developers to construct and maintain libraries and large applications, for both the Java SE and EE Platforms.
  • 15. JPMS – Module System THUS  Strong encapsulation (among modules)  Better architectural design  Improve security  Reliable configuration  Introduce dependency management (sort of)  Space efficiency & performance
  • 16. JPMS – Module Definition A module is a named, self-describing collection of code and data. And contains packages (classes & interfaces), resources, other static information (e.g. META-INF) module modul.demo.a {} // depends on java.base module modul.demo.bank { exports modul.demo.bank; } module modul.demo.bank.client { requires modul.demo.bank; }
  • 17. JPMS – Module Definition Directory Structure ModulDemo2BankClient/ → Eclipse project base src/ → Source folder modul.demo.bank.client/ → module source folder module-info.java → module descriptor modul/demo/bank/client/ → package BankClient.java → java Class Jar Structure (1 jar = 1 module) META-INF/ META-INF/MANIFEST.MF module-info.class modul/demo/bank/client/BankClient.class
  • 18. JPMS – Platform Modules Java Platform is divided into modules. https://blog.codecentric.de/files/2015/11/jdk-tr1.png
  • 19. JPMS – Platform Modules Base Module (“java.base”)  Always present  Only module known by module system  Exports all of the platform's core packages  Every other module depends implicitly upon base module  Base module depends upon no other module module java.base { exports java.io; exports java.lang; exports java.lang.invoke; exports java.lang.module; exports java.lang.ref; exports java.lang.reflect; exports java.net; ... }
  • 20. JPMS – Using Modules Module Path  Means to locate whole modules (similar to classpath)  Resolves module dependences  System path contains module artifacts (jars) or module directories e.g. %JAVA_HOME%/jmods;libs  If the module system is unable to find a dependent module or if it encounters two modules w/ same name then the compiler or virtual machine report an error and exits
  • 21. JPMS – Module Resolution module com.my.pkg { requires org.apaçi.lib; } module com.my.app { requires com.my.pkg; requires java.sql; } module org.apaçi.lib { } Resolution Start Here: Initial Application Module MODULE GRAPH Explicit dependence vs Implicit dependence module java.sql { requires java.logging; requires java.xml; exports java.sql; exports javax.sql; exports javax.transaction.xa; }
  • 22. JPMS – Implied Readibility // Application Code Driver d = DriverManager.getDriver(url); java.sql→ Connection c = d.connect(url, props); java.sql→ d.getParentLogger().info("Connection acquired"); java.logging→ How can the application access “java.logging” module? Revise “java.sql” module descriptor module java.sql { requires public java.logging; requires public java.xml; exports java.sql; exports javax.sql; exports javax.transaction.xa; } If one module exports a package containing a type whose signature refers to a package in a second module then the declaration of the first module should include a requires public dependence upon the second.
  • 23. JPMS – Unnamed Module  All jars loaded from the classpath are considered as a member of Unnamed Module.  Ensures that every type is associated with a module.  The unnamed module reads every other module (i.e. all named & built-in platform modules) Thus existing Java 8 application compile and run on Java 9. (unless api's are deprecated or removed)  The unnamed module exports all of its packages. But named module can not access types in the unnamed module.  If a package is defined in both a named module and the unnamed module then the package in the unnamed module is ignored.
  • 24. JPMS – Unnamed Module If our application is written before Java 8, module dependences in Java 9 is as below: Grey covered jars are in classpath, therefore they are defined as “unnamed module”.
  • 25. JPMS – Bottom-Up Migration What to migrate to Java 9? Find the intermodule dependencies (using jdeps) Use buttom-up approach to select&migrate to modules. com-foo-app.jar com-foo-bar.jar org-baz-qux.jar It is easy to migrate “org.baz.qux” to module system. Because it has no dependences.
  • 26. JPMS – Bottom-Up Migration Continue to bottom-up migration What if “org.baz.qux.jar” is maintained by another organization and cannot be converted to a named module? Is it possible to migrate other jars into modules?
  • 27. JPMS – Automatic Module  A jar w/o module descriptor in modulepath is defined as automatic module  Accesses all other modules (named and unnamed)  Implicitly exports all of its packages to Unnamed Module  Can be read explicitly by named modules.  Mudule name is automatically determined using jar name (subject to change)  Removes the file extension  Removes trailing version number  replaces all the non-alphanumeric characters with dots mysql-connector-java-6.1.6.jar → mysql.connector.java
  • 28. JPMS – Top-Down Migration − Application jars are not module. − JRE is Java9. Therefore, platform (java.*) modules exists in environment. − Want to convert application jars into modules.  Only com-foo-app.jar and com-foo-bar.jar can be converted.  org-baz-qux.jar is maintained by another organization. com-foo-app.jar com-foo-bar.jar org-baz-qux.jar Current Situation
  • 29. JPMS – Top-Down Migration module com.foo.bar { requires org.baz.qux; } module com.foo.app { requires com.foo.bar; requires java.sql; }  Move org-baz-qux.jar to module-path. It will have automodule name: org-baz-qux.jar → org.baz.qux  Now com-foo-app.jar and com-foo-bar.jar can depend upon org.baz.qux module. org.baz.qux → Automatic Module
  • 30. JPMS – Top-Down Migration Notes  Automatic Modules allow an existing application to be migrated to modules from the top down (first app.jar then other jars)  To migrate the jars in classpath  Find and analyze interdependency (jdeps)  Convert the source code of your organization into modules  Move 3rd party jars into module-path to make them automodule thus, your module code may depend/read the automodules. (until module versions of 3rd party jars are prepared)
  • 31. JPMS – Module Types Summary MODULE TYPE MODULE DESCRIPTOR LOCATION Application Module Exists Module-path Automatic Module Doesn't exist Module-path Unnamed Module Exists or Doesn't exist Class-path Platform Module Exists Platform's Module-path MODULE TYPE EXPORTS PACKAGES CAN READ MODULES CAN BE READ BY MODULES Application Module Explicitly Application Platform Automatic Application Automatic Unnamed Platform Module Explicitly Platform All types of modules Unnamed Module All All types of modules Application Automatic Unnamed Automatic Module All All types of modules Application Automatic Unnamed
  • 33. JPMS – Service Loader  Provides loose-coupling among modules.  Based on the java.util.ServiceLoader mechanism.  Service Loader locates the service providers at run-time by searching jars in classpath.
  • 34. JPMS – Service Loader Service Loader in Java 7 Service File: META-INF /services /com.example.CodecSet File Content: com.example.impl.StandardCodecs # Standard codecs Code: Iterator<CodecSet> codecs = ServiceLoader.load(CodecSet.class).iterator(); foreach(codec) { //select codec instance. }
  • 35. JPMS – Services module java.sql { requires public java.logging; requires public java.xml; exports java.sql; exports javax.sql; exports javax.transaction.xa; uses java.sql.Driver; } module com.mysql.jdbc { requires java.sql; requires org.slf4j; exports com.mysql.jdbc; provides java.sql.Driver with com.mysql.jdbc.Driver; }
  • 36. JPMS – Services Highligts Declaring service relation in module declaration  Improves efficiency and clarity (locating/loading time)  Provides compile&run time accessibility check  Provides compile-time type compatibility check  Provides safe linking prior to run-time  Provides capability to run Ahead-of-Time Compilation
  • 37. JPMS – Reflection package java.lang.reflect; public final class Module { public String getName(); public ModuleDescriptor getDescriptor(); public ClassLoader getClassLoader(); public boolean canRead(Module target); public boolean isExported(String packageName); }  Every Class object has an associated Module object  Module object returns by the Class::getModule method  ModuleDescriptor class represents module descriptor  canRead() tells whether the module can read the target module  isExported() tells whether the module exports given package  Class.forName() continues to work as soon as the reflected class is exported in target module and readable by caller module.
  • 38. JPMS – Class Loader  Modules names/packages don't have to interfere with each other  A module has to be loaded/associated by only one class loader  Exception: Unnamed Module is associated by all class loaders.  Existing Hierarchy is preserved.  Bootstrap and extension class loaders load platform modules.  Application class loader loads classes of modules in the module path.  Load classes from one or more modules.
  • 39.  Besides application modules, new layer may contain upgradable platform modules as soon as they are loaded from a different location.  During resolution process, modules in new layer can read modules in lower layers. CONTAINER JPMS – Layers Upgradeable modules v1.0v1.1  Container launches the application w/ initial layer (L1)  An upgrade necessitates and v1.1 modules are loaded in a new layer (L2) on the top of initial layer (L1) from a different jar location.  Container performs this loading operation by using module reflection API's and dynamic class loading.
  • 40. JPMS – Qualified Exports  Allows a package to be exported to specifically-named modules. module java.base { ... exports sun.reflect to java.corba, java.logging, java.sql, java.sql.rowset, jdk.scripting.nashorn; }  Can be used to hide the internal implementation from the unintended users.  Provides a kind of module security. (e.g. in container environment)
  • 42. TTTTTTTTTTTTTTTTTTTTTTTHHHHHHHHH HHHHHHHHH AAA NNNNNNNN NNNNNNNNKKKKKKKKK KKKKKKK T:::::::::::::::::::::TH:::::::H H:::::::H A:::A N:::::::N N::::::NK:::::::K K:::::K T:::::::::::::::::::::TH:::::::H H:::::::H A:::::A N::::::::N N::::::NK:::::::K K:::::K T:::::TT:::::::TT:::::THH::::::H H::::::HH A:::::::A N:::::::::N N::::::NK:::::::K K::::::K TTTTTT T:::::T TTTTTT H:::::H H:::::H A:::::::::A N::::::::::N N::::::NKK::::::K K:::::KKK T:::::T H:::::H H:::::H A:::::A:::::A N:::::::::::N N::::::N K:::::K K:::::K T:::::T H::::::HHHHH::::::H A:::::A A:::::A N:::::::N::::N N::::::N K::::::K:::::K T:::::T H:::::::::::::::::H A:::::A A:::::A N::::::N N::::N N::::::N K:::::::::::K T:::::T H:::::::::::::::::H A:::::A A:::::A N::::::N N::::N:::::::N K:::::::::::K T:::::T H::::::HHHHH::::::H A:::::AAAAAAAAA:::::A N::::::N N:::::::::::N K::::::K:::::K T:::::T H:::::H H:::::H A:::::::::::::::::::::A N::::::N N::::::::::N K:::::K K:::::K T:::::T H:::::H H:::::H A:::::AAAAAAAAAAAAA:::::A N::::::N N:::::::::NKK::::::K K:::::KKK TT:::::::TT HH::::::H H::::::HH A:::::A A:::::A N::::::N N::::::::NK:::::::K K::::::K T:::::::::T H:::::::H H:::::::H A:::::A A:::::A N::::::N N:::::::NK:::::::K K:::::K T:::::::::T H:::::::H H:::::::H A:::::A A:::::A N::::::N N::::::NK:::::::K K:::::K TTTTTTTTTTT HHHHHHHHH HHHHHHHHHAAAAAAA AAAAAAANNNNNNNN NNNNNNNKKKKKKKKK KKKKKKK YYYYYYY YYYYYYY OOOOOOOOO UUUUUUUU UUUUUUUU Y:::::Y Y:::::Y OO:::::::::OO U::::::U U::::::U Y:::::Y Y:::::Y OO:::::::::::::OO U::::::U U::::::U Y::::::Y Y::::::YO:::::::OOO:::::::OUU:::::U U:::::UU YYY:::::Y Y:::::YYYO::::::O O::::::O U:::::U U:::::U Y:::::Y Y:::::Y O:::::O O:::::O U:::::D D:::::U Y:::::Y:::::Y O:::::O O:::::O U:::::D D:::::U Y:::::::::Y O:::::O O:::::O U:::::D D:::::U Y:::::::Y O:::::O O:::::O U:::::D D:::::U Y:::::Y O:::::O O:::::O U:::::D D:::::U Y:::::Y O:::::O O:::::O U:::::D D:::::U Y:::::Y O::::::O O::::::O U::::::U U::::::U Y:::::Y O:::::::OOO:::::::O U:::::::UUU:::::::U YYYY:::::YYYY OO:::::::::::::OO UU:::::::::::::UU Y:::::::::::Y OO:::::::::OO UU:::::::::UU YYYYYYYYYYYYY OOOOOOOOO UUUUUUUUU