SlideShare ist ein Scribd-Unternehmen logo
1 von 53
Downloaden Sie, um offline zu lesen
© Copyright Azul Systems 2016
© Copyright Azul Systems 2015
@speakjava
JDK 9: Big Changes
To Make Java Smaller
Simon Ritter
Deputy CTO, Azul Systems
1
© Copyright Azul Systems 2016
API Structural Changes
© Copyright Azul Systems 2016
API Classification
 Supported, intended for public use
– JCP specified: java.*, javax.*
– JDK specific: some com.sun.*, some jdk.*
 Unsupported, not intended for public use
– Mostly sun.*
– Most infamous is sun.misc.Unsafe
3
© 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
 JDK 8 has 18 interfaces, 23 classes, 64 fields, 358
methods and 20 constructors that have been deprecated
–None have been removed
–Until now
4
© Copyright Azul Systems 2016
JDK 9: Incompatible Changes
 Encapsulate most JDK internal APIs
 Remove a small number of supported APIs
– 6 in total, all add/remove PropertyChangeListener
– Already flagged in JSR 337 (Java SE 8), JEP 162
 Change the binary structure of the JRE and JDK
 New version string format
 A single underscore will no longer be allowed as an
identifier in source code
5
© Copyright Azul Systems 2016
Removed In JDK 9
 Endorsed standard API override mechanism
 Extension mechanism
 No longer required now we have a module system
6
© Copyright Azul Systems 2016
Most Popular Unsupported APIs
1. sun.misc.BASE64Encoder
2. sun.misc.Unsafe
3. sun.misc.BASE64Decoder
7
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
8
© Copyright Azul Systems 2016
JEP 260 Proposal
 Encapsulate all non-critical JDK-internal APIs
 Encapsulate all critical JDK-internal APIs, for which
supported replacements exist in JDK 8
 Do not encapsulate other critical JDK-internal APIs
– Deprecate these in JDK 9
– Plan to encapsulate or remove them in JDK 10
– Provide command-line option to access encapsulated
critical APIs
9
© Copyright Azul Systems 2016
Reviewing Your Own Code
 jdeps tool
– Introduced in JDK 8, improved in JDK 9
– Maven jdeps plugin
jdeps –jdkinternals path/myapp.jar
10
path/myapp.jar -> /opt/jdk1.8.0/jre/lib/rt.jar
<unnamed> (myapp.jar)
-> sun.misc.Unsafe
-> ...
© Copyright Azul Systems 2016
Project Jigsaw And Modules
© Copyright Azul Systems 2016
Goals For Project Jigsaw
 Make Java SE more scalable and flexible
– Internet of Things
– Microservices
 Improve security, maintainability and performance
 Simplify construction, deployment and maintenance of
large scale applications
 Eliminate classpath hell
12
© Copyright Azul Systems 2016
Module Fundamentals
 Module is a grouping of code
– For Java this is a collection of packages
 Modules can contain other things
– Native code
– Resources
– Configuration data
13
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
14
module com.azul.zoop {
}
module-info.java
com/azul/zoop/alpha/Name.java
com/azul/zoop/alpha/Position.java
com/azul/zoop/beta/Animal.java
com/azul/zoop/beta/Zoo.java
© Copyright Azul Systems 2016
Module Dependencies
module com.azul.zoop {
requires com.azul.zeta;
} com.azul.zoop
com.azul.zeta
© Copyright Azul Systems 2016
Module Dependencies
module com.azul.app {
requires com.azul.zoop;
requires java.sql;
}
com.azul.app
com.azul.zoop java.sql
© Copyright Azul Systems 2016
Module Dependency Graph
com.azul.app
java.base
java.sqlcom.azul.zoop
com.azul.zeta
java.xml java.logging
explicit
implicit
© Copyright Azul Systems 2016
Readability v. Dependency
com.azul.app
java.sql
java.logging
module java.sql {
requires public java.logging;
}
Driver d = …
Logger l = d.getParentLogger();
l.log(“azul’);
Implied readability
© Copyright Azul Systems 2016
Module Implied Readability Graph
com.azul.app
java.base
java.sqlcom.azul.zoop
com.azul.zeta
java.xml java.logging
explicit
implicit
implied
© Copyright Azul Systems 2016
Package Visibility
module com.azul.zoop {
requires com.azul.zeta;
exports com.azul.zoop.alpha;
exports com.azul.zoop.beta to com.azul.app;
}
com.azul.zoop
com.azul.zoop.alpha
com.azul.zoop.beta
com.azul.zoop.thetacom.azul.app only
© Copyright Azul Systems 2016
More Package Visibility
weak module com.azul.zoop {
requires com.azul.zeta;
}
com.azul.zoop
com.azul.zoop.alpha
com.azul.zoop.beta com.azul.zoop.theta
© Copyright Azul Systems 2016
Even More Package Visibility
module com.azul.zoop {
requires com.azul.zeta;
exports com.azul.zoop.alpha;
exports com.azul.zoop.beta to com.azul.app;
exports private com.azul.theta;
}
com.azul.zoop
com.azul.zoop.theta
REFLECTIONGENERAL
com.azul.zoop.alpha
com.azul.zoop.beta
com.azul.app only
© Copyright Azul Systems 2016
Accessibility
 For a package to be visible
– The package must be exported by the containing module
– The containing module must be read by the using module
 Public types from those packages can then be used
com.azul.zoopcom.azul.app
reads
© Copyright Azul Systems 2016
Java Accessibility (pre-JDK 9)
public
protected
<package>
private
© Copyright Azul Systems 2016
Java Accessibility (JDK 9)
public to everyone
public, but only to specific modules
public only within a module
protected
<package>
private
public ≠ accessible (fundamental change to Java)
© Copyright Azul Systems 2016
JDK 8 Dependencies
© Copyright Azul Systems 2016
JDK 9 Platform Modules
27
java.se
java.compact3
java.compact2
java.compact1
java.scripting
java.instrument
java.base
java.logging
java.sql
java.sql.rowset
java.xml
java.desktop
java.rmi
java.prefs
java.datatransfer
java.compiler
java.management
java.security.jgss
java.naming
java.security.sasl
All modules depend on java.base
no implied
readability=
© Copyright Azul Systems 2016
JDK 9 Platform Modules
28
java.se.ee java.se
java.xml.bind
java.corba
java.compiler
java.desktop
java.annotations.common
java.rmi
java.datatransfer
java.management
java.xml.ws
java.naming
java.transaction
java.activation
All modules depend on java.base
© Copyright Azul Systems 2016
Using Modules
© Copyright Azul Systems 2016
Module Path
$ javac –modulepath dir1:dir2:dir3
© Copyright Azul Systems 2016
Compilation With Module Path
31
$ javac –modulepath mods –d mods 
src/module-info.java 
src/com/azul/zoop/alpha/Name.java
mods/module-info.class
mods/com/azul/zoop/alpha/Name.class
src/module-info.java
src/com/azul/zoop/alpha/Name.java
© Copyright Azul Systems 2016
Application Execution
 -modulepath can be abbreviated to -mp
$ java –mp mods –m com.azul.app/com.azul.app.Main
Azul application initialised!
module name main class
© Copyright Azul Systems 2016
Packaging With Modular JAR Files
mods/module-info.class
mods/com/azul/app/Main.class
$ jar --create --file mylib/app.jar 
--main-class com.azul.app.Main 
-C mods .
module-info.class
com/azul/app/Main.class
app.jar
© Copyright Azul Systems 2016
JAR Files & Module Information
$ jar --file mylib/app.jar –p
Name:
com.azul.zoop
Requires:
com.azul.zeta
java.base [MANDATED]
java.sql
Main class:
com.azul.zoop.Main
© Copyright Azul Systems 2016
Application Execution (JAR)
$ java –mp mylib:mods –m com.azul.app
Azul application initialised!
© Copyright Azul Systems 2016
Linking
Modular run-time
image
…confbin
jlink
$ jlink --modulepath $JDKMODS 
--addmods java.base –output myimage
$ myimage/bin/java –listmods
java.base@9.0
© Copyright Azul Systems 2016
Linking An Application
$ jlink --modulepath $JDKMODS:$MYMODS 
--addmods com.azul.app –output myimage
$ myimage/bin/java –listmods
java.base@9.0
java.logging@9.0
java.sql@9.0
java.xml@9.0
com.azul.app@1.0
com.azul.zoop@1.0
com.azul.zeta@1.0
Version numbering for
information purposes only
“It is not a goal of the module
system to solve the version-
selection problem”
© Copyright Azul Systems 2016
Application Migration
© Copyright Azul Systems 2016
Typical Application (JDK 8)
jar
jar
jar
JDK
jar
jarjar
jar jar
jar
jar
jar
jar
Classpath
© Copyright Azul Systems 2016
Typical Application (JDK 9)
jar
jar
jar
module
java.base
module
java.desktop
module
java.datatransfer
module
java.xml
jar
jarjar
jar jar
jar
jar
jar
jar
Unnamed
module
© Copyright Azul Systems 2016
Sample Application
myapp.ja
r
libgl.jar
mylib.jar
gluegen.jar jogl.jar
module
java.base
module
java.desktop
module
java.datatransfer
module
java.xml
© Copyright Azul Systems 2016
Run Application With Classpath
$ java –classpath 
lib/myapp.jar: 
lib/mylib.jar: 
lib/libgl.jar: 
lib/gluegen.jar: 
lib/jogl.jar: 
myapp.Main
© Copyright Azul Systems 2016
Sample Application
module
myapp.ja
r
libgl.jar
module
mylib.jar
gluegen.jar jogl.jar
module
java.base
module
java.desktop
module
java.datatransfer
module
java.xml
© Copyright Azul Systems 2016
Application module-info.java
module myapp {
requires mylib;
requires java.base;
requires java.sql;
requires libgl; ????
requires gluegen; ????
requires jogl; ????
}
© Copyright Azul Systems 2016
Sample Application
module
myapp.ja
r
module
libgl.jar
module
mylib.jar
module
gluegen.jar
module
jogl.jar
module
java.base
module
java.desktop
module
java.datatransfer
module
java.xml
© Copyright Azul Systems 2016
Automatic Modules
 Real modules
 Simply place unmodified jar file on module path
– Rather than classpath
 No changes to JAR file
 Module name derived from JAR file name
 Exports all its packages
– No selectivity
 Automatically requires all modules on the module path
46
© Copyright Azul Systems 2016
Application Module Dependencies
module
myapp.ja
r
module
libgl.jar
module
mylib.jar
module
gluegen.jar
module
jogl.jar
module
java.base
module
java.desktop
module
java.datatransfer
module
java.xml
Implicit
Explicit
© Copyright Azul Systems 2016
Run Application With Modules
$ java –classpath 
lib/myapp.jar: 
lib/mylib.jar: 
lib/libgl.jar: 
lib/gluegen.jar: 
lib/jogl.jar: 
myapp.Main
$ java –mp mylib:lib –m myapp
© Copyright Azul Systems 2016
Summary
© Copyright Azul Systems 2016
Summary
 Modularisation is a big change for Java
– JVM/JRE rather than language/APIs
 Potentially disruptive changes to exposure of non-public APIs
– Is it safe?
 Developing modular code will require some learning
– Not a huge change, though
50
© Copyright Azul Systems 2016
Zulu.org
 Azul binary distribution of OpenJDK source code
 Passed all TCK tests
 Completely FREE!
– Pay us if you’d like enterprise level support
 Just announced: Embedded Zulu support for ARM 32-bit
– Intel already supported
– “Requires no licensing fee”
51
© Copyright Azul Systems 2016
Further Information
 openjdk.java.net
 openjdk.java.net/jeps
 openjdk.java.net/projects/jigsaw
 jcp.org
52
© Copyright Azul Systems 2016
© Copyright Azul Systems 2015
@speakjava
Thank You!
Simon Ritter
Deputy CTO, Azul Systems
53

Weitere ähnliche Inhalte

Was ist angesagt?

WSO2Con Asia 2014 - WSO2 AppDev Platform for the Connected Business
WSO2Con Asia 2014 - WSO2 AppDev Platform for the Connected BusinessWSO2Con Asia 2014 - WSO2 AppDev Platform for the Connected Business
WSO2Con Asia 2014 - WSO2 AppDev Platform for the Connected Business
WSO2
 
continuous delivery at SAP IT for devopscon Israel
continuous delivery at SAP IT for devopscon Israelcontinuous delivery at SAP IT for devopscon Israel
continuous delivery at SAP IT for devopscon Israel
Alon Aizenberg
 

Was ist angesagt? (20)

JSR377: Desktop Java
JSR377: Desktop JavaJSR377: Desktop Java
JSR377: Desktop Java
 
Jigsaw modularity
Jigsaw modularityJigsaw modularity
Jigsaw modularity
 
Moving Towards JDK 12
Moving Towards JDK 12Moving Towards JDK 12
Moving Towards JDK 12
 
Java modules using project jigsaw@jdk 9
Java modules using project jigsaw@jdk 9Java modules using project jigsaw@jdk 9
Java modules using project jigsaw@jdk 9
 
Serverless Java - Challenges and Triumphs
Serverless Java - Challenges and TriumphsServerless Java - Challenges and Triumphs
Serverless Java - Challenges and Triumphs
 
Project Jigsaw in JDK9
Project Jigsaw in JDK9Project Jigsaw in JDK9
Project Jigsaw in JDK9
 
Serverless Java: JJUG CCC 2019
Serverless Java: JJUG CCC 2019Serverless Java: JJUG CCC 2019
Serverless Java: JJUG CCC 2019
 
Java 12 - New features in action
Java 12 -   New features in actionJava 12 -   New features in action
Java 12 - New features in action
 
The latest features coming to Java 12
The latest features coming to Java 12The latest features coming to Java 12
The latest features coming to Java 12
 
Java modularity: life after Java 9
Java modularity: life after Java 9Java modularity: life after Java 9
Java modularity: life after Java 9
 
Advanced modular development
Advanced modular development  Advanced modular development
Advanced modular development
 
WSO2 AppDev platform
WSO2 AppDev platformWSO2 AppDev platform
WSO2 AppDev platform
 
WSO2Con Asia 2014 - WSO2 AppDev Platform for the Connected Business
WSO2Con Asia 2014 - WSO2 AppDev Platform for the Connected BusinessWSO2Con Asia 2014 - WSO2 AppDev Platform for the Connected Business
WSO2Con Asia 2014 - WSO2 AppDev Platform for the Connected Business
 
Os Haase
Os HaaseOs Haase
Os Haase
 
Oracle Developer Cloud - 소개 (신기능 포함)
Oracle Developer Cloud - 소개 (신기능 포함)Oracle Developer Cloud - 소개 (신기능 포함)
Oracle Developer Cloud - 소개 (신기능 포함)
 
How we took our server side application to the cloud and liked what we got, B...
How we took our server side application to the cloud and liked what we got, B...How we took our server side application to the cloud and liked what we got, B...
How we took our server side application to the cloud and liked what we got, B...
 
Migrating From Applets to Java Desktop Apps in JavaFX
Migrating From Applets to Java Desktop Apps in JavaFXMigrating From Applets to Java Desktop Apps in JavaFX
Migrating From Applets to Java Desktop Apps in JavaFX
 
Migrating Beyond Java 8
Migrating Beyond Java 8Migrating Beyond Java 8
Migrating Beyond Java 8
 
continuous delivery at SAP IT for devopscon Israel
continuous delivery at SAP IT for devopscon Israelcontinuous delivery at SAP IT for devopscon Israel
continuous delivery at SAP IT for devopscon Israel
 
Java 9 New Features
Java 9 New FeaturesJava 9 New Features
Java 9 New Features
 

Andere mochten auch

BioConference Live Genetics 2013
BioConference Live Genetics 2013BioConference Live Genetics 2013
BioConference Live Genetics 2013
LabRoots, Inc.
 
Unleashing People Potential
Unleashing People PotentialUnleashing People Potential
Unleashing People Potential
Anand Desai
 
συναντηση υπουργειου εθνικης αμυνης
συναντηση υπουργειου εθνικης αμυνηςσυναντηση υπουργειου εθνικης αμυνης
συναντηση υπουργειου εθνικης αμυνης
ATHANASIOS KAVVADAS
 
Stay sane. Test for real.
Stay sane. Test for real.Stay sane. Test for real.
Stay sane. Test for real.
Bartosz Majsak
 
Совместная работа в облачной среде: общие сведения для определенияподходящей ...
Совместная работа в облачной среде: общие сведения для
определенияподходящей ...Совместная работа в облачной среде: общие сведения для
определенияподходящей ...
Совместная работа в облачной среде: общие сведения для определенияподходящей ...
SaaS.ru Portal
 
Social media nonprofitcenter0913
Social media nonprofitcenter0913Social media nonprofitcenter0913
Social media nonprofitcenter0913
Jan Hirabayashi
 

Andere mochten auch (20)

New Jersey: Your Dream Home Destination
New Jersey: Your Dream Home DestinationNew Jersey: Your Dream Home Destination
New Jersey: Your Dream Home Destination
 
Presentation1
Presentation1Presentation1
Presentation1
 
Downlight for commercial lighting application
Downlight for commercial lighting application Downlight for commercial lighting application
Downlight for commercial lighting application
 
Home Buyers Guide
Home Buyers Guide Home Buyers Guide
Home Buyers Guide
 
Henry dunant
Henry dunantHenry dunant
Henry dunant
 
BioConference Live Genetics 2013
BioConference Live Genetics 2013BioConference Live Genetics 2013
BioConference Live Genetics 2013
 
Unleashing People Potential
Unleashing People PotentialUnleashing People Potential
Unleashing People Potential
 
συναντηση υπουργειου εθνικης αμυνης
συναντηση υπουργειου εθνικης αμυνηςσυναντηση υπουργειου εθνικης αμυνης
συναντηση υπουργειου εθνικης αμυνης
 
Stay sane. Test for real.
Stay sane. Test for real.Stay sane. Test for real.
Stay sane. Test for real.
 
Trabajo
TrabajoTrabajo
Trabajo
 
Wearable Computing Devices - The Next Big Thing!
Wearable Computing Devices - The Next Big Thing!Wearable Computing Devices - The Next Big Thing!
Wearable Computing Devices - The Next Big Thing!
 
Совместная работа в облачной среде: общие сведения для определенияподходящей ...
Совместная работа в облачной среде: общие сведения для
определенияподходящей ...Совместная работа в облачной среде: общие сведения для
определенияподходящей ...
Совместная работа в облачной среде: общие сведения для определенияподходящей ...
 
Plato
PlatoPlato
Plato
 
Silicon valley and the search for immortality — the future of healthcare
Silicon valley and the search for immortality — the future of healthcareSilicon valley and the search for immortality — the future of healthcare
Silicon valley and the search for immortality — the future of healthcare
 
cert
certcert
cert
 
Book secrets of success of IIIT model
Book secrets of success of IIIT modelBook secrets of success of IIIT model
Book secrets of success of IIIT model
 
Understanding the bronchiectasis prognosis
Understanding the bronchiectasis prognosisUnderstanding the bronchiectasis prognosis
Understanding the bronchiectasis prognosis
 
Social media nonprofitcenter0913
Social media nonprofitcenter0913Social media nonprofitcenter0913
Social media nonprofitcenter0913
 
Moving Trends 2013
Moving Trends 2013Moving Trends 2013
Moving Trends 2013
 
Slamit 7, an ERASMUS+ Course
Slamit 7, an ERASMUS+ Course Slamit 7, an ERASMUS+ Course
Slamit 7, an ERASMUS+ Course
 

Ähnlich wie Voxxed Days Thessaloniki 2016 - Keynote - JDK 9 : Big Changes To Make Java Smaller

Why should i switch to Java SE 7
Why should i switch to Java SE 7Why should i switch to Java SE 7
Why should i switch to Java SE 7
Vinay H G
 
GR8Conf 2011: Adopting Grails
GR8Conf 2011: Adopting GrailsGR8Conf 2011: Adopting Grails
GR8Conf 2011: Adopting Grails
GR8Conf
 
Adopting Grails - GR8Conf Europe
Adopting Grails - GR8Conf EuropeAdopting Grails - GR8Conf Europe
Adopting Grails - GR8Conf Europe
KlausBaumecker
 

Ähnlich wie Voxxed Days Thessaloniki 2016 - Keynote - JDK 9 : Big Changes To Make Java Smaller (20)

JDK 9 Deep Dive
JDK 9 Deep DiveJDK 9 Deep Dive
JDK 9 Deep Dive
 
JDK 9 and JDK 10 Deep Dive
JDK 9 and JDK 10 Deep DiveJDK 9 and JDK 10 Deep Dive
JDK 9 and JDK 10 Deep Dive
 
Project Jigsaw in JDK 9: Modularity Comes To Java
Project Jigsaw in JDK 9: Modularity Comes To JavaProject Jigsaw in JDK 9: Modularity Comes To Java
Project Jigsaw in JDK 9: Modularity Comes To Java
 
Modern Java Workshop
Modern Java WorkshopModern Java Workshop
Modern Java Workshop
 
JDK 9: Migrating Applications
JDK 9: Migrating ApplicationsJDK 9: Migrating Applications
JDK 9: Migrating Applications
 
JDK-9: Modules and Java Linker
JDK-9: Modules and Java LinkerJDK-9: Modules and Java Linker
JDK-9: Modules and Java Linker
 
Preparing your code for Java 9
Preparing your code for Java 9Preparing your code for Java 9
Preparing your code for Java 9
 
JDK 9: The Start of a New Future for Java
JDK 9: The Start of a New Future for JavaJDK 9: The Start of a New Future for Java
JDK 9: The Start of a New Future for Java
 
JavaOne 2016: Life after Modularity
JavaOne 2016: Life after ModularityJavaOne 2016: Life after Modularity
JavaOne 2016: Life after Modularity
 
JVMs in Containers - Best Practices
JVMs in Containers - Best PracticesJVMs in Containers - Best Practices
JVMs in Containers - Best Practices
 
JVMs in Containers
JVMs in ContainersJVMs in Containers
JVMs in Containers
 
Java Cloud and Container Ready
Java Cloud and Container ReadyJava Cloud and Container Ready
Java Cloud and Container Ready
 
Java modules
Java modulesJava modules
Java modules
 
JDK 10 Java Module System
JDK 10 Java Module SystemJDK 10 Java Module System
JDK 10 Java Module System
 
JDK 9, 10, 11 and Beyond
JDK 9, 10, 11 and BeyondJDK 9, 10, 11 and Beyond
JDK 9, 10, 11 and Beyond
 
Why should i switch to Java SE 7
Why should i switch to Java SE 7Why should i switch to Java SE 7
Why should i switch to Java SE 7
 
Production Time Profiling Out of the Box
Production Time Profiling Out of the BoxProduction Time Profiling Out of the Box
Production Time Profiling Out of the Box
 
GR8Conf 2011: Adopting Grails
GR8Conf 2011: Adopting GrailsGR8Conf 2011: Adopting Grails
GR8Conf 2011: Adopting Grails
 
Adopting Grails - GR8Conf Europe
Adopting Grails - GR8Conf EuropeAdopting Grails - GR8Conf Europe
Adopting Grails - GR8Conf Europe
 
Java9
Java9Java9
Java9
 

Mehr von Voxxed Days Thessaloniki

Mehr von Voxxed Days Thessaloniki (13)

Voxxed Days Thesaloniki 2016 - The Long Road
Voxxed Days Thesaloniki 2016 - The Long RoadVoxxed Days Thesaloniki 2016 - The Long Road
Voxxed Days Thesaloniki 2016 - The Long Road
 
Voxxed Days Thesaloniki 2016 - Scaling react.js applications
Voxxed Days Thesaloniki 2016 - Scaling react.js applicationsVoxxed Days Thesaloniki 2016 - Scaling react.js applications
Voxxed Days Thesaloniki 2016 - Scaling react.js applications
 
Voxxed Days Thesaloniki 2016 - Herding cats to a firefight
Voxxed Days Thesaloniki 2016 - Herding cats to a firefightVoxxed Days Thesaloniki 2016 - Herding cats to a firefight
Voxxed Days Thesaloniki 2016 - Herding cats to a firefight
 
Voxxed Days Thessaloniki 2016 - Web assembly : the browser vm we were waiting...
Voxxed Days Thessaloniki 2016 - Web assembly : the browser vm we were waiting...Voxxed Days Thessaloniki 2016 - Web assembly : the browser vm we were waiting...
Voxxed Days Thessaloniki 2016 - Web assembly : the browser vm we were waiting...
 
Voxxed Days Thesaloniki 2016 - Streaming Engines for Big Data
Voxxed Days Thesaloniki 2016 - Streaming Engines for Big DataVoxxed Days Thesaloniki 2016 - Streaming Engines for Big Data
Voxxed Days Thesaloniki 2016 - Streaming Engines for Big Data
 
Voxxed Days Thessaloniki 2016 - Documentation Avoidance
Voxxed Days Thessaloniki 2016 - Documentation AvoidanceVoxxed Days Thessaloniki 2016 - Documentation Avoidance
Voxxed Days Thessaloniki 2016 - Documentation Avoidance
 
Voxxed Days Thesaloniki 2016 - Rightsize Your Services with WildFly & WildFly...
Voxxed Days Thesaloniki 2016 - Rightsize Your Services with WildFly & WildFly...Voxxed Days Thesaloniki 2016 - Rightsize Your Services with WildFly & WildFly...
Voxxed Days Thesaloniki 2016 - Rightsize Your Services with WildFly & WildFly...
 
Voxxed Days Thessaloniki 2016 - Microservices in production
Voxxed Days Thessaloniki 2016 - Microservices in productionVoxxed Days Thessaloniki 2016 - Microservices in production
Voxxed Days Thessaloniki 2016 - Microservices in production
 
Voxxed Days Thesaloniki 2016 - Whirlwind tour through the HTTP2 spec
Voxxed Days Thesaloniki 2016 - Whirlwind tour through the HTTP2 specVoxxed Days Thesaloniki 2016 - Whirlwind tour through the HTTP2 spec
Voxxed Days Thesaloniki 2016 - Whirlwind tour through the HTTP2 spec
 
Voxxed Days Thesaloniki 2016 - Machine Learning for Developers
Voxxed Days Thesaloniki 2016 - Machine Learning for DevelopersVoxxed Days Thesaloniki 2016 - Machine Learning for Developers
Voxxed Days Thesaloniki 2016 - Machine Learning for Developers
 
Voxxed Days Thessaloniki 2016 - Continuous Delivery: Jenkins, Docker and Spri...
Voxxed Days Thessaloniki 2016 - Continuous Delivery: Jenkins, Docker and Spri...Voxxed Days Thessaloniki 2016 - Continuous Delivery: Jenkins, Docker and Spri...
Voxxed Days Thessaloniki 2016 - Continuous Delivery: Jenkins, Docker and Spri...
 
Voxxed Days Thesaloniki 2016 - 5 must have patterns for your web-scale micros...
Voxxed Days Thesaloniki 2016 - 5 must have patterns for your web-scale micros...Voxxed Days Thesaloniki 2016 - 5 must have patterns for your web-scale micros...
Voxxed Days Thesaloniki 2016 - 5 must have patterns for your web-scale micros...
 
Voxxed Days Thesaloniki 2016 - A journey to Open Source Technologies on Azure
Voxxed Days Thesaloniki 2016 - A journey to Open Source Technologies on AzureVoxxed Days Thesaloniki 2016 - A journey to Open Source Technologies on Azure
Voxxed Days Thesaloniki 2016 - A journey to Open Source Technologies on Azure
 

Kürzlich hochgeladen

introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 

Kürzlich hochgeladen (20)

introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
Pharm-D Biostatistics and Research methodology
Pharm-D Biostatistics and Research methodologyPharm-D Biostatistics and Research methodology
Pharm-D Biostatistics and Research methodology
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxBUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 

Voxxed Days Thessaloniki 2016 - Keynote - JDK 9 : Big Changes To Make Java Smaller

  • 1. © Copyright Azul Systems 2016 © Copyright Azul Systems 2015 @speakjava JDK 9: Big Changes To Make Java Smaller Simon Ritter Deputy CTO, Azul Systems 1
  • 2. © Copyright Azul Systems 2016 API Structural Changes
  • 3. © 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 3
  • 4. © Copyright Azul Systems 2016 General Java Compatability Policy  If an application uses only supported APIs on version N of Java it should work on version N+1, even without recompilation  Supported APIs can be removed –But only with advanced notice  JDK 8 has 18 interfaces, 23 classes, 64 fields, 358 methods and 20 constructors that have been deprecated –None have been removed –Until now 4
  • 5. © Copyright Azul Systems 2016 JDK 9: Incompatible Changes  Encapsulate most JDK internal APIs  Remove a small number of supported APIs – 6 in total, all add/remove PropertyChangeListener – Already flagged in JSR 337 (Java SE 8), JEP 162  Change the binary structure of the JRE and JDK  New version string format  A single underscore will no longer be allowed as an identifier in source code 5
  • 6. © Copyright Azul Systems 2016 Removed In JDK 9  Endorsed standard API override mechanism  Extension mechanism  No longer required now we have a module system 6
  • 7. © Copyright Azul Systems 2016 Most Popular Unsupported APIs 1. sun.misc.BASE64Encoder 2. sun.misc.Unsafe 3. sun.misc.BASE64Decoder 7 Oracle dataset based on internal application code
  • 8. © 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 8
  • 9. © Copyright Azul Systems 2016 JEP 260 Proposal  Encapsulate all non-critical JDK-internal APIs  Encapsulate all critical JDK-internal APIs, for which supported replacements exist in JDK 8  Do not encapsulate other critical JDK-internal APIs – Deprecate these in JDK 9 – Plan to encapsulate or remove them in JDK 10 – Provide command-line option to access encapsulated critical APIs 9
  • 10. © Copyright Azul Systems 2016 Reviewing Your Own Code  jdeps tool – Introduced in JDK 8, improved in JDK 9 – Maven jdeps plugin jdeps –jdkinternals path/myapp.jar 10 path/myapp.jar -> /opt/jdk1.8.0/jre/lib/rt.jar <unnamed> (myapp.jar) -> sun.misc.Unsafe -> ...
  • 11. © Copyright Azul Systems 2016 Project Jigsaw And Modules
  • 12. © Copyright Azul Systems 2016 Goals For Project Jigsaw  Make Java SE more scalable and flexible – Internet of Things – Microservices  Improve security, maintainability and performance  Simplify construction, deployment and maintenance of large scale applications  Eliminate classpath hell 12
  • 13. © Copyright Azul Systems 2016 Module Fundamentals  Module is a grouping of code – For Java this is a collection of packages  Modules can contain other things – Native code – Resources – Configuration data 13 com.azul.zoop com.azul.zoop.alpha.Name com.azul.zoop.alpha.Position com.azul.zoop.beta.Animal com.azul.zoop.beta.Zoo
  • 14. © Copyright Azul Systems 2016 Module Declaration 14 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
  • 15. © Copyright Azul Systems 2016 Module Dependencies module com.azul.zoop { requires com.azul.zeta; } com.azul.zoop com.azul.zeta
  • 16. © 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
  • 17. © Copyright Azul Systems 2016 Module Dependency Graph com.azul.app java.base java.sqlcom.azul.zoop com.azul.zeta java.xml java.logging explicit implicit
  • 18. © 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’); Implied readability
  • 19. © Copyright Azul Systems 2016 Module Implied Readability Graph com.azul.app java.base java.sqlcom.azul.zoop com.azul.zeta java.xml java.logging explicit implicit implied
  • 20. © Copyright Azul Systems 2016 Package Visibility module com.azul.zoop { requires com.azul.zeta; exports com.azul.zoop.alpha; exports com.azul.zoop.beta to com.azul.app; } com.azul.zoop com.azul.zoop.alpha com.azul.zoop.beta com.azul.zoop.thetacom.azul.app only
  • 21. © Copyright Azul Systems 2016 More Package Visibility weak module com.azul.zoop { requires com.azul.zeta; } com.azul.zoop com.azul.zoop.alpha com.azul.zoop.beta com.azul.zoop.theta
  • 22. © Copyright Azul Systems 2016 Even More Package Visibility module com.azul.zoop { requires com.azul.zeta; exports com.azul.zoop.alpha; exports com.azul.zoop.beta to com.azul.app; exports private com.azul.theta; } com.azul.zoop com.azul.zoop.theta REFLECTIONGENERAL com.azul.zoop.alpha com.azul.zoop.beta com.azul.app only
  • 23. © 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
  • 24. © Copyright Azul Systems 2016 Java Accessibility (pre-JDK 9) public protected <package> private
  • 25. © 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)
  • 26. © Copyright Azul Systems 2016 JDK 8 Dependencies
  • 27. © Copyright Azul Systems 2016 JDK 9 Platform Modules 27 java.se java.compact3 java.compact2 java.compact1 java.scripting java.instrument java.base java.logging java.sql java.sql.rowset java.xml java.desktop java.rmi java.prefs java.datatransfer java.compiler java.management java.security.jgss java.naming java.security.sasl All modules depend on java.base no implied readability=
  • 28. © Copyright Azul Systems 2016 JDK 9 Platform Modules 28 java.se.ee java.se java.xml.bind java.corba java.compiler java.desktop java.annotations.common java.rmi java.datatransfer java.management java.xml.ws java.naming java.transaction java.activation All modules depend on java.base
  • 29. © Copyright Azul Systems 2016 Using Modules
  • 30. © Copyright Azul Systems 2016 Module Path $ javac –modulepath dir1:dir2:dir3
  • 31. © Copyright Azul Systems 2016 Compilation With Module Path 31 $ javac –modulepath mods –d mods src/module-info.java src/com/azul/zoop/alpha/Name.java mods/module-info.class mods/com/azul/zoop/alpha/Name.class src/module-info.java src/com/azul/zoop/alpha/Name.java
  • 32. © Copyright Azul Systems 2016 Application Execution  -modulepath can be abbreviated to -mp $ java –mp mods –m com.azul.app/com.azul.app.Main Azul application initialised! module name main class
  • 33. © Copyright Azul Systems 2016 Packaging With Modular JAR Files mods/module-info.class mods/com/azul/app/Main.class $ jar --create --file mylib/app.jar --main-class com.azul.app.Main -C mods . module-info.class com/azul/app/Main.class app.jar
  • 34. © Copyright Azul Systems 2016 JAR Files & Module Information $ jar --file mylib/app.jar –p Name: com.azul.zoop Requires: com.azul.zeta java.base [MANDATED] java.sql Main class: com.azul.zoop.Main
  • 35. © Copyright Azul Systems 2016 Application Execution (JAR) $ java –mp mylib:mods –m com.azul.app Azul application initialised!
  • 36. © 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
  • 37. © Copyright Azul Systems 2016 Linking An Application $ jlink --modulepath $JDKMODS:$MYMODS --addmods com.azul.app –output myimage $ myimage/bin/java –listmods java.base@9.0 java.logging@9.0 java.sql@9.0 java.xml@9.0 com.azul.app@1.0 com.azul.zoop@1.0 com.azul.zeta@1.0 Version numbering for information purposes only “It is not a goal of the module system to solve the version- selection problem”
  • 38. © Copyright Azul Systems 2016 Application Migration
  • 39. © Copyright Azul Systems 2016 Typical Application (JDK 8) jar jar jar JDK jar jarjar jar jar jar jar jar jar Classpath
  • 40. © Copyright Azul Systems 2016 Typical Application (JDK 9) jar jar jar module java.base module java.desktop module java.datatransfer module java.xml jar jarjar jar jar jar jar jar jar Unnamed module
  • 41. © Copyright Azul Systems 2016 Sample Application myapp.ja r libgl.jar mylib.jar gluegen.jar jogl.jar module java.base module java.desktop module java.datatransfer module java.xml
  • 42. © Copyright Azul Systems 2016 Run Application With Classpath $ java –classpath lib/myapp.jar: lib/mylib.jar: lib/libgl.jar: lib/gluegen.jar: lib/jogl.jar: myapp.Main
  • 43. © Copyright Azul Systems 2016 Sample Application module myapp.ja r libgl.jar module mylib.jar gluegen.jar jogl.jar module java.base module java.desktop module java.datatransfer module java.xml
  • 44. © Copyright Azul Systems 2016 Application module-info.java module myapp { requires mylib; requires java.base; requires java.sql; requires libgl; ???? requires gluegen; ???? requires jogl; ???? }
  • 45. © Copyright Azul Systems 2016 Sample Application module myapp.ja r module libgl.jar module mylib.jar module gluegen.jar module jogl.jar module java.base module java.desktop module java.datatransfer module java.xml
  • 46. © Copyright Azul Systems 2016 Automatic Modules  Real modules  Simply place unmodified jar file on module path – Rather than classpath  No changes to JAR file  Module name derived from JAR file name  Exports all its packages – No selectivity  Automatically requires all modules on the module path 46
  • 47. © Copyright Azul Systems 2016 Application Module Dependencies module myapp.ja r module libgl.jar module mylib.jar module gluegen.jar module jogl.jar module java.base module java.desktop module java.datatransfer module java.xml Implicit Explicit
  • 48. © Copyright Azul Systems 2016 Run Application With Modules $ java –classpath lib/myapp.jar: lib/mylib.jar: lib/libgl.jar: lib/gluegen.jar: lib/jogl.jar: myapp.Main $ java –mp mylib:lib –m myapp
  • 49. © Copyright Azul Systems 2016 Summary
  • 50. © Copyright Azul Systems 2016 Summary  Modularisation is a big change for Java – JVM/JRE rather than language/APIs  Potentially disruptive changes to exposure of non-public APIs – Is it safe?  Developing modular code will require some learning – Not a huge change, though 50
  • 51. © Copyright Azul Systems 2016 Zulu.org  Azul binary distribution of OpenJDK source code  Passed all TCK tests  Completely FREE! – Pay us if you’d like enterprise level support  Just announced: Embedded Zulu support for ARM 32-bit – Intel already supported – “Requires no licensing fee” 51
  • 52. © Copyright Azul Systems 2016 Further Information  openjdk.java.net  openjdk.java.net/jeps  openjdk.java.net/projects/jigsaw  jcp.org 52
  • 53. © Copyright Azul Systems 2016 © Copyright Azul Systems 2015 @speakjava Thank You! Simon Ritter Deputy CTO, Azul Systems 53