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
Ad

More Related Content

What's hot (20)

Object Oriented Programming with Java
Object Oriented Programming with JavaObject Oriented Programming with Java
Object Oriented Programming with Java
backdoor
 
JAVA-PPT'S.pptx
JAVA-PPT'S.pptxJAVA-PPT'S.pptx
JAVA-PPT'S.pptx
RaazIndia
 
C# Basics
C# BasicsC# Basics
C# Basics
Sunil OS
 
Object Oriented Programming Using C++
Object Oriented Programming Using C++Object Oriented Programming Using C++
Object Oriented Programming Using C++
Muhammad Waqas
 
Java interface
Java interface Java interface
Java interface
HoneyChintal
 
Jdbc
Jdbc   Jdbc
Jdbc
Ishucs
 
Java IO
Java IOJava IO
Java IO
UTSAB NEUPANE
 
Java Garbage Collection - How it works
Java Garbage Collection - How it worksJava Garbage Collection - How it works
Java Garbage Collection - How it works
Mindfire Solutions
 
Friend function & friend class
Friend function & friend classFriend function & friend class
Friend function & friend class
Abhishek Wadhwa
 
Cracking OCA and OCP Java 8 Exams
Cracking OCA and OCP Java 8 ExamsCracking OCA and OCP Java 8 Exams
Cracking OCA and OCP Java 8 Exams
Ganesh Samarthyam
 
7.data types in c#
7.data types in c#7.data types in c#
7.data types in c#
Zeeshan Ahmad
 
Object Oriented Programming Principles
Object Oriented Programming PrinciplesObject Oriented Programming Principles
Object Oriented Programming Principles
Andrew Ferlitsch
 
Core Java
Core JavaCore Java
Core Java
Priyanka Pradhan
 
Virtual function in C++ Pure Virtual Function
Virtual function in C++ Pure Virtual Function Virtual function in C++ Pure Virtual Function
Virtual function in C++ Pure Virtual Function
Kamlesh Makvana
 
Inheritance in JAVA PPT
Inheritance  in JAVA PPTInheritance  in JAVA PPT
Inheritance in JAVA PPT
Pooja Jaiswal
 
Control statements in java
Control statements in javaControl statements in java
Control statements in java
Madishetty Prathibha
 
Java access modifiers
Java access modifiersJava access modifiers
Java access modifiers
Khaled Adnan
 
Intro to Java
Intro to JavaIntro to Java
Intro to Java
karianneban
 
Java Thread Synchronization
Java Thread SynchronizationJava Thread Synchronization
Java Thread Synchronization
Benj Del Mundo
 
JAVA INTRODUCTION - 1
JAVA INTRODUCTION - 1JAVA INTRODUCTION - 1
JAVA INTRODUCTION - 1
Infoviaan Technologies
 
Object Oriented Programming with Java
Object Oriented Programming with JavaObject Oriented Programming with Java
Object Oriented Programming with Java
backdoor
 
JAVA-PPT'S.pptx
JAVA-PPT'S.pptxJAVA-PPT'S.pptx
JAVA-PPT'S.pptx
RaazIndia
 
Object Oriented Programming Using C++
Object Oriented Programming Using C++Object Oriented Programming Using C++
Object Oriented Programming Using C++
Muhammad Waqas
 
Java Garbage Collection - How it works
Java Garbage Collection - How it worksJava Garbage Collection - How it works
Java Garbage Collection - How it works
Mindfire Solutions
 
Friend function & friend class
Friend function & friend classFriend function & friend class
Friend function & friend class
Abhishek Wadhwa
 
Cracking OCA and OCP Java 8 Exams
Cracking OCA and OCP Java 8 ExamsCracking OCA and OCP Java 8 Exams
Cracking OCA and OCP Java 8 Exams
Ganesh Samarthyam
 
Object Oriented Programming Principles
Object Oriented Programming PrinciplesObject Oriented Programming Principles
Object Oriented Programming Principles
Andrew Ferlitsch
 
Virtual function in C++ Pure Virtual Function
Virtual function in C++ Pure Virtual Function Virtual function in C++ Pure Virtual Function
Virtual function in C++ Pure Virtual Function
Kamlesh Makvana
 
Inheritance in JAVA PPT
Inheritance  in JAVA PPTInheritance  in JAVA PPT
Inheritance in JAVA PPT
Pooja Jaiswal
 
Java access modifiers
Java access modifiersJava access modifiers
Java access modifiers
Khaled Adnan
 
Java Thread Synchronization
Java Thread SynchronizationJava Thread Synchronization
Java Thread Synchronization
Benj Del Mundo
 

Similar to Java 9 Module System (20)

Java9
Java9Java9
Java9
Software Infrastructure
 
Java 9 / Jigsaw - AJUG/VJUG session
Java 9 / Jigsaw - AJUG/VJUG  sessionJava 9 / Jigsaw - AJUG/VJUG  session
Java 9 / Jigsaw - AJUG/VJUG session
Mani Sarkar
 
Modules all the way down: OSGi and the Java Platform Module System
Modules all the way down: OSGi and the Java Platform Module SystemModules all the way down: OSGi and the Java Platform Module System
Modules all the way down: OSGi and the Java Platform Module System
Tim Ellison
 
Java8 - Under the hood
Java8 - Under the hoodJava8 - Under the hood
Java8 - Under the hood
Lakshmi Narasimhan
 
java basic for begginers
java basic for begginersjava basic for begginers
java basic for begginers
divaskrgupta007
 
Manuel - SPR - Intro to Java Language_2016
Manuel - SPR - Intro to Java Language_2016Manuel - SPR - Intro to Java Language_2016
Manuel - SPR - Intro to Java Language_2016
Manuel Fomitescu
 
Java Platform Module System
Java Platform Module SystemJava Platform Module System
Java Platform Module System
Vignesh Ramesh
 
Java 9 Modularity and Project Jigsaw
Java 9 Modularity and Project JigsawJava 9 Modularity and Project Jigsaw
Java 9 Modularity and Project Jigsaw
Comsysto Reply GmbH
 
OOP with Java
OOP with JavaOOP with Java
OOP with Java
OmegaHub
 
Java 9 / Jigsaw - LJC / VJUG session (hackday session)
Java 9 / Jigsaw - LJC / VJUG session (hackday session)Java 9 / Jigsaw - LJC / VJUG session (hackday session)
Java 9 / Jigsaw - LJC / VJUG session (hackday session)
Mani Sarkar
 
What's New in Java 9
What's New in Java 9What's New in Java 9
What's New in Java 9
Richard Langlois P. Eng.
 
Unit 1 – Introduction to Java- (Shilpa R).pptx
Unit 1 – Introduction to Java- (Shilpa R).pptxUnit 1 – Introduction to Java- (Shilpa R).pptx
Unit 1 – Introduction to Java- (Shilpa R).pptx
shilpar780389
 
Apache Maven supports all Java (JokerConf 2018)
Apache Maven supports all Java (JokerConf 2018)Apache Maven supports all Java (JokerConf 2018)
Apache Maven supports all Java (JokerConf 2018)
Robert Scholte
 
Jddk
JddkJddk
Jddk
tatoriver
 
Java 9
Java 9Java 9
Java 9
Netesh Kumar
 
Introduction to java
Introduction to java Introduction to java
Introduction to java
Sandeep Rawat
 
Apache Maven supports ALL Java (Javaland 2019)
Apache Maven supports ALL Java (Javaland 2019)Apache Maven supports ALL Java (Javaland 2019)
Apache Maven supports ALL Java (Javaland 2019)
Robert Scholte
 
Presentation5
Presentation5Presentation5
Presentation5
Natasha Bains
 
Java 9: Deep Dive into Modularity and Dealing with Migration Issues
Java 9: Deep Dive into Modularity and Dealing with Migration IssuesJava 9: Deep Dive into Modularity and Dealing with Migration Issues
Java 9: Deep Dive into Modularity and Dealing with Migration Issues
GlobalLogic Ukraine
 
Preparing for java 9 modules upload
Preparing for java 9 modules uploadPreparing for java 9 modules upload
Preparing for java 9 modules upload
Ryan Cuprak
 
Java 9 / Jigsaw - AJUG/VJUG session
Java 9 / Jigsaw - AJUG/VJUG  sessionJava 9 / Jigsaw - AJUG/VJUG  session
Java 9 / Jigsaw - AJUG/VJUG session
Mani Sarkar
 
Modules all the way down: OSGi and the Java Platform Module System
Modules all the way down: OSGi and the Java Platform Module SystemModules all the way down: OSGi and the Java Platform Module System
Modules all the way down: OSGi and the Java Platform Module System
Tim Ellison
 
java basic for begginers
java basic for begginersjava basic for begginers
java basic for begginers
divaskrgupta007
 
Manuel - SPR - Intro to Java Language_2016
Manuel - SPR - Intro to Java Language_2016Manuel - SPR - Intro to Java Language_2016
Manuel - SPR - Intro to Java Language_2016
Manuel Fomitescu
 
Java Platform Module System
Java Platform Module SystemJava Platform Module System
Java Platform Module System
Vignesh Ramesh
 
Java 9 Modularity and Project Jigsaw
Java 9 Modularity and Project JigsawJava 9 Modularity and Project Jigsaw
Java 9 Modularity and Project Jigsaw
Comsysto Reply GmbH
 
OOP with Java
OOP with JavaOOP with Java
OOP with Java
OmegaHub
 
Java 9 / Jigsaw - LJC / VJUG session (hackday session)
Java 9 / Jigsaw - LJC / VJUG session (hackday session)Java 9 / Jigsaw - LJC / VJUG session (hackday session)
Java 9 / Jigsaw - LJC / VJUG session (hackday session)
Mani Sarkar
 
Unit 1 – Introduction to Java- (Shilpa R).pptx
Unit 1 – Introduction to Java- (Shilpa R).pptxUnit 1 – Introduction to Java- (Shilpa R).pptx
Unit 1 – Introduction to Java- (Shilpa R).pptx
shilpar780389
 
Apache Maven supports all Java (JokerConf 2018)
Apache Maven supports all Java (JokerConf 2018)Apache Maven supports all Java (JokerConf 2018)
Apache Maven supports all Java (JokerConf 2018)
Robert Scholte
 
Introduction to java
Introduction to java Introduction to java
Introduction to java
Sandeep Rawat
 
Apache Maven supports ALL Java (Javaland 2019)
Apache Maven supports ALL Java (Javaland 2019)Apache Maven supports ALL Java (Javaland 2019)
Apache Maven supports ALL Java (Javaland 2019)
Robert Scholte
 
Java 9: Deep Dive into Modularity and Dealing with Migration Issues
Java 9: Deep Dive into Modularity and Dealing with Migration IssuesJava 9: Deep Dive into Modularity and Dealing with Migration Issues
Java 9: Deep Dive into Modularity and Dealing with Migration Issues
GlobalLogic Ukraine
 
Preparing for java 9 modules upload
Preparing for java 9 modules uploadPreparing for java 9 modules upload
Preparing for java 9 modules upload
Ryan Cuprak
 
Ad

Recently uploaded (20)

The Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdfThe Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdf
drewplanas10
 
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Ranjan Baisak
 
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Dele Amefo
 
Top 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docxTop 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docx
Portli
 
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage DashboardsAdobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
BradBedford3
 
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Andre Hora
 
Expand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchangeExpand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchange
Fexle Services Pvt. Ltd.
 
Landscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature ReviewLandscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature Review
Hironori Washizaki
 
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software DevelopmentSecure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Shubham Joshi
 
Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025
mu394968
 
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Eric D. Schabell
 
How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...
How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...
How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...
Egor Kaleynik
 
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRYLEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
NidaFarooq10
 
Adobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest VersionAdobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest Version
kashifyounis067
 
Download YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full ActivatedDownload YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full Activated
saniamalik72555
 
Revolutionizing Residential Wi-Fi PPT.pptx
Revolutionizing Residential Wi-Fi PPT.pptxRevolutionizing Residential Wi-Fi PPT.pptx
Revolutionizing Residential Wi-Fi PPT.pptx
nidhisingh691197
 
EASEUS Partition Master Crack + License Code
EASEUS Partition Master Crack + License CodeEASEUS Partition Master Crack + License Code
EASEUS Partition Master Crack + License Code
aneelaramzan63
 
Exploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the FutureExploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the Future
ICS
 
PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025
mu394968
 
Automation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath CertificateAutomation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath Certificate
VICTOR MAESTRE RAMIREZ
 
The Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdfThe Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdf
drewplanas10
 
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Ranjan Baisak
 
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Dele Amefo
 
Top 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docxTop 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docx
Portli
 
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage DashboardsAdobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
BradBedford3
 
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Andre Hora
 
Expand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchangeExpand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchange
Fexle Services Pvt. Ltd.
 
Landscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature ReviewLandscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature Review
Hironori Washizaki
 
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software DevelopmentSecure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Shubham Joshi
 
Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025
mu394968
 
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Eric D. Schabell
 
How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...
How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...
How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...
Egor Kaleynik
 
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRYLEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
NidaFarooq10
 
Adobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest VersionAdobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest Version
kashifyounis067
 
Download YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full ActivatedDownload YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full Activated
saniamalik72555
 
Revolutionizing Residential Wi-Fi PPT.pptx
Revolutionizing Residential Wi-Fi PPT.pptxRevolutionizing Residential Wi-Fi PPT.pptx
Revolutionizing Residential Wi-Fi PPT.pptx
nidhisingh691197
 
EASEUS Partition Master Crack + License Code
EASEUS Partition Master Crack + License CodeEASEUS Partition Master Crack + License Code
EASEUS Partition Master Crack + License Code
aneelaramzan63
 
Exploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the FutureExploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the Future
ICS
 
PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025
mu394968
 
Automation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath CertificateAutomation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath Certificate
VICTOR MAESTRE RAMIREZ
 
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