SlideShare ist ein Scribd-Unternehmen logo
1 von 27
Downloaden Sie, um offline zu lesen
Java SE 9, Project Jigsaw
Elek Márton
@anzix
2015 March
DPC Consulting
Java 9 roadmap
2015/09/08 Mark Reinhold: The state of the
module system (Java 9 b83)
2015/12/10 Feature Complete
2016/02/04 All Tests Run
2016/02/25 Rampdown Start
2016/04/21 Zero Bug Bounce
2016/06/16 Rampdown Phase 2
2016/07/21 Final Release Candidate
2016/09/22 General Availability
Planned features
Improvements
● Java REPL
● HTTP2 Client
● UTF-8 Property files
● Microbenchmark Suite
● Compiler improvements
● Money and Currency API, JSR-354 (?)
● JSON API (? - proposed to be dropped)
● ProcessAPI update (pid, process list)
● HTML5 Javadoc
● Make G1 the default GC algorithm
● Remove deprecated GC combinations
Modularization
Related JEPs/JSR
JEP 200: The Modular JDK
JEP 201: Modular Source Code
JEP 220: Modular Run-Time Images
JEP 162: Prepare for Modularization (Java8)
JSR 376: Java Platform Module System
Good source:
Mark Reinhold: The state of the module system
Getting started
Create your first module:
● traditional JAR file with
● module-info.java
module hu.dpc.java9.logger {
}
Compile the module
● Could be compiled with standard tools (maven) if
there are no dependencies
● Command line tools are also changed
javac
-d /tmp/modules/hu.dpc.java9.logger
-modulepath /tmp/modules
-sourcepath src/main/java …..java
Using the logger
Create your first module:
● traditional JAR file with
● module-info.java
module hu.dpc.java9.logger {
exports hu.dpc.java9.logger;
}
Using logger
public class App {
public static void main(String[] args)
LoggerFactory.getLogger().log("Hello world");
}
}
module hu.dpc.java9.app {
requires hu.dpc.java9.logger;
}
Package level dependencies
Source: M Reinhold: The state of the
module system
Why we need classloaders?
● Classloader is for creating new classes
● Reference to a class could be used even without
explicit export
LoggerImpl
App
LoggerFactory
Logger
exports
requires
Compile and run
javac
-d /tmp/modules/hu.dpc.java9.logger
-modulepath /tmp/modules
-sourcepath src/main/java ....java
java
-mp /tmp/modules
-m hu.dpc.java9.app/hu.dpc.java9.App
Backward compatibility
java
-mp /tmp/modules
-m hu.dpc.java9.app/hu.dpc.java9.App
java
-cp /tmp/modules/hu.dpc.java9.app:/tmp/modules/hu.dpc.java9.logger
hu.dpc.java9.App
Packaging: jmod
● Accommodate native code, configuration files, and
other kinds of data
● "Whether this new format, provisionally named
“JMOD,” should be standardized is an open
question."
JDK modules
● Most of the APIs
are modularized
● can’t be used
without proper
requires in
module-info
Service layer
Service Layer
logger-framework.jar
logger-mysql.jar
interface Logger{...}
class MysqlLogger{...}
class LoggerFactory{...
Service Layer
logger-framework.jar
logger-syslog.jar
interface Logger{...}
class SyslogLogger{...}
class LoggerFactory{...
Service Layer - Java 6-8
Service Provider Interface
● Which are the implementation of a specific
interface?
ServiceLoader<Logger> loggers =
ServiceLoader.load(Logger.class);
for (Logger logger: loggers) {
logger.log("hello world");
}
}
Service Layer - Java 6-8
ServiceLoader<Logger> loggers =
ServiceLoader.load(Logger.class);
for (Logger logger: loggers) {
logger.log("hello world");
}
}
Definition (in the jar file):
META-INF/services/hu.dpc.java9.logger.Logger
hu.dpc.java9.logger.internal.LoggerImpl
Service Layer - Java 6-8
logger-framework.jar
logger-mysql.jar
interface Logger{...}
class MysqlLogger{...}
class LoggerFactory{...
Service Layer - Java 9
Usage:
ServiceLoader<Logger> loggers =
ServiceLoader.load(Logger.class);
for (Logger logger: loggers) {
logger.log("hello world");
}
}
Definition
In the hu.dpc.java9.logger module:
module hu.dpc.java9.logger {
exports hu.dpc.java9.logger;
provides hu.dpc.java9.logger.Logger
with hu.dpc.java9.logger.internal.LoggerImpl;
}
In the hu.dpc.java9.app module
module hu.dpc.java9.app {
requires hu.dpc.java9.logger;
use hu.dpc.java9.logger.Logger;
}
Non requirements
● Modularize the Java Language Specification
● Modularize the Java Virtual Machine Specification
● Multiple versions
● Version selection
● Strict classloader requirements
See: http://openjdk.java.net/projects/jigsaw/spec/reqs/
Java 9 vs OSGi
Java 9 / Jigsaw OSGi
metadata module-info.java (nincs meta adat) META-INF
classpath
separation
exports/requires Import-Package/Export-Package
classpath++ transitive imports, fragment bundle/dynamic import
classloader
hierarchy
ClassLoader: unspecified strict, per bundle
service layer static (get implementations) dynamic (get implemetations +
start/stop listeners)
services interface + implementation for the standard
services (logging, config...)
versioning no yes
Summary/Future
● Summary
– classpath separation: private/public
– service locator (based on existing SPI)
– modularized JVM APIs
● Not scope
– versioning!
– strict class loader rules
● Shoud be upgraded:
– all the IDEs
– all the build tools (maven, gradle)
– all the JVM based languages (Scala, Clojure)
● SPI
– could be more widely adopted

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (20)

Java 9 preview
Java 9 previewJava 9 preview
Java 9 preview
 
Desiging for Modularity with Java 9
Desiging for Modularity with Java 9Desiging for Modularity with Java 9
Desiging for Modularity with Java 9
 
Modular JavaScript
Modular JavaScriptModular JavaScript
Modular JavaScript
 
Modular Java
Modular JavaModular Java
Modular Java
 
Migrating to Java 9 Modules
Migrating to Java 9 ModulesMigrating to Java 9 Modules
Migrating to Java 9 Modules
 
Discuss about java 9 with latest features
Discuss about java 9 with latest featuresDiscuss about java 9 with latest features
Discuss about java 9 with latest features
 
Java Modularity: the Year After
Java Modularity: the Year AfterJava Modularity: the Year After
Java Modularity: the Year After
 
Modular Java applications with OSGi on Apache Karaf
Modular Java applications with OSGi on Apache KarafModular Java applications with OSGi on Apache Karaf
Modular Java applications with OSGi on Apache Karaf
 
Polygot Java EE on the GraalVM
Polygot Java EE on the GraalVMPolygot Java EE on the GraalVM
Polygot Java EE on the GraalVM
 
Developing modular Java applications
Developing modular Java applicationsDeveloping modular Java applications
Developing modular Java applications
 
Karaf ee-apachecon eu-2012
Karaf ee-apachecon eu-2012Karaf ee-apachecon eu-2012
Karaf ee-apachecon eu-2012
 
Java 9 Module System Introduction
Java 9 Module System IntroductionJava 9 Module System Introduction
Java 9 Module System Introduction
 
Java 9 and the impact on Maven Projects (ApacheCon Europe 2016)
Java 9 and the impact on Maven Projects (ApacheCon Europe 2016)Java 9 and the impact on Maven Projects (ApacheCon Europe 2016)
Java 9 and the impact on Maven Projects (ApacheCon Europe 2016)
 
JDK 9: Big Changes To Make Java Smaller
JDK 9: Big Changes To Make Java SmallerJDK 9: Big Changes To Make Java Smaller
JDK 9: Big Changes To Make Java Smaller
 
Java 9 and Beyond
Java 9 and BeyondJava 9 and Beyond
Java 9 and Beyond
 
Java9 and the impact on Maven Projects (JFall 2016)
Java9 and the impact on Maven Projects (JFall 2016)Java9 and the impact on Maven Projects (JFall 2016)
Java9 and the impact on Maven Projects (JFall 2016)
 
Java 9 and the impact on Maven Projects (JavaOne 2016)
Java 9 and the impact on Maven Projects (JavaOne 2016)Java 9 and the impact on Maven Projects (JavaOne 2016)
Java 9 and the impact on Maven Projects (JavaOne 2016)
 
Why jakarta ee matters (ConFoo 2021)
Why jakarta ee matters (ConFoo 2021)Why jakarta ee matters (ConFoo 2021)
Why jakarta ee matters (ConFoo 2021)
 
JDK 9: Big Changes To Make Java Smaller
JDK 9: Big Changes To Make Java SmallerJDK 9: Big Changes To Make Java Smaller
JDK 9: Big Changes To Make Java Smaller
 
Preparing your code for Java 9
Preparing your code for Java 9Preparing your code for Java 9
Preparing your code for Java 9
 

Andere mochten auch

Andere mochten auch (6)

Full stack security
Full stack securityFull stack security
Full stack security
 
Docker+java
Docker+javaDocker+java
Docker+java
 
Két Java fejlesztő első Scala projektje
Két Java fejlesztő első Scala projektjeKét Java fejlesztő első Scala projektje
Két Java fejlesztő első Scala projektje
 
OSGi in 5 minutes
OSGi in 5 minutesOSGi in 5 minutes
OSGi in 5 minutes
 
Introducing the Jahia Log Analyzer
Introducing the Jahia Log AnalyzerIntroducing the Jahia Log Analyzer
Introducing the Jahia Log Analyzer
 
Provisioning the IoT
Provisioning the IoTProvisioning the IoT
Provisioning the IoT
 

Ähnlich wie Java 9 and Project Jigsaw

Java 7 and 8, what does it mean for you
Java 7 and 8, what does it mean for youJava 7 and 8, what does it mean for you
Java 7 and 8, what does it mean for you
Dmitry Buzdin
 
Gustavo Garnica: Evolución de la Plataforma Java y lo que Significa para Ti
Gustavo Garnica: Evolución de la Plataforma Java y lo que Significa para TiGustavo Garnica: Evolución de la Plataforma Java y lo que Significa para Ti
Gustavo Garnica: Evolución de la Plataforma Java y lo que Significa para Ti
Software Guru
 
Jigsaw - Javaforum 2015Q4
Jigsaw - Javaforum 2015Q4Jigsaw - Javaforum 2015Q4
Jigsaw - Javaforum 2015Q4
Rikard Thulin
 

Ähnlich wie Java 9 and Project Jigsaw (20)

Java 9-10 What's New
Java 9-10 What's NewJava 9-10 What's New
Java 9-10 What's New
 
Java 7 and 8, what does it mean for you
Java 7 and 8, what does it mean for youJava 7 and 8, what does it mean for you
Java 7 and 8, what does it mean for you
 
Java 9 sneak peek
Java 9 sneak peekJava 9 sneak peek
Java 9 sneak peek
 
Jozi-JUG JDK 9 Unconference
Jozi-JUG JDK 9 UnconferenceJozi-JUG JDK 9 Unconference
Jozi-JUG JDK 9 Unconference
 
Java and OpenJDK: disecting the ecosystem
Java and OpenJDK: disecting the ecosystemJava and OpenJDK: disecting the ecosystem
Java and OpenJDK: disecting the ecosystem
 
Retour JavaOne 2009
Retour JavaOne 2009Retour JavaOne 2009
Retour JavaOne 2009
 
Spring Update | July 2023
Spring Update | July 2023Spring Update | July 2023
Spring Update | July 2023
 
Gustavo Garnica: Evolución de la Plataforma Java y lo que Significa para Ti
Gustavo Garnica: Evolución de la Plataforma Java y lo que Significa para TiGustavo Garnica: Evolución de la Plataforma Java y lo que Significa para Ti
Gustavo Garnica: Evolución de la Plataforma Java y lo que Significa para Ti
 
JavaOne 2014 - Scalable JavaScript Applications with Project Nashorn [CON6423]
JavaOne 2014 - Scalable JavaScript Applications with Project Nashorn [CON6423]JavaOne 2014 - Scalable JavaScript Applications with Project Nashorn [CON6423]
JavaOne 2014 - Scalable JavaScript Applications with Project Nashorn [CON6423]
 
Grails 101
Grails 101Grails 101
Grails 101
 
Jigsaw - Javaforum 2015Q4
Jigsaw - Javaforum 2015Q4Jigsaw - Javaforum 2015Q4
Jigsaw - Javaforum 2015Q4
 
Spring Boot 3 And Beyond
Spring Boot 3 And BeyondSpring Boot 3 And Beyond
Spring Boot 3 And Beyond
 
Java 8 -12: da Oracle a Eclipse. Due anni e una rivoluzione
Java 8 -12: da Oracle a Eclipse. Due anni e una rivoluzioneJava 8 -12: da Oracle a Eclipse. Due anni e una rivoluzione
Java 8 -12: da Oracle a Eclipse. Due anni e una rivoluzione
 
Java 9/10/11 - What's new and why you should upgrade
Java 9/10/11 - What's new and why you should upgradeJava 9/10/11 - What's new and why you should upgrade
Java 9/10/11 - What's new and why you should upgrade
 
AMIS Oracle OpenWorld 2013 Review Part 3 - Fusion Middleware
AMIS Oracle OpenWorld 2013 Review Part 3 - Fusion MiddlewareAMIS Oracle OpenWorld 2013 Review Part 3 - Fusion Middleware
AMIS Oracle OpenWorld 2013 Review Part 3 - Fusion Middleware
 
Java 22_ Unwrapped: What You Need to Know.pptx
Java 22_ Unwrapped: What You Need to Know.pptxJava 22_ Unwrapped: What You Need to Know.pptx
Java 22_ Unwrapped: What You Need to Know.pptx
 
コミュニティ開発に参加しよう!
コミュニティ開発に参加しよう!コミュニティ開発に参加しよう!
コミュニティ開発に参加しよう!
 
JCConf 2018 - Retrospect and Prospect of Java
JCConf 2018 - Retrospect and Prospect of JavaJCConf 2018 - Retrospect and Prospect of Java
JCConf 2018 - Retrospect and Prospect of Java
 
Whats new in Java 9,10,11,12
Whats new in Java 9,10,11,12Whats new in Java 9,10,11,12
Whats new in Java 9,10,11,12
 
JDD2015: Taste of new in Java 9 - Arkadiusz Sokołowski
JDD2015: Taste of new in Java 9 - Arkadiusz SokołowskiJDD2015: Taste of new in Java 9 - Arkadiusz Sokołowski
JDD2015: Taste of new in Java 9 - Arkadiusz Sokołowski
 

Mehr von DPC Consulting Ltd (7)

Scaling on AWS
Scaling on AWSScaling on AWS
Scaling on AWS
 
Jsonp coding dojo
Jsonp coding dojoJsonp coding dojo
Jsonp coding dojo
 
Microservices and modularity with java
Microservices and modularity with javaMicroservices and modularity with java
Microservices and modularity with java
 
Garbage First Garbage Collector Algorithm
Garbage First Garbage Collector AlgorithmGarbage First Garbage Collector Algorithm
Garbage First Garbage Collector Algorithm
 
Power tools in Java
Power tools in JavaPower tools in Java
Power tools in Java
 
Server in your Client
Server in your ClientServer in your Client
Server in your Client
 
OSGi as Enterprise Integration Platform
OSGi as Enterprise Integration PlatformOSGi as Enterprise Integration Platform
OSGi as Enterprise Integration Platform
 

Kürzlich hochgeladen

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Kürzlich hochgeladen (20)

CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 

Java 9 and Project Jigsaw

  • 1. Java SE 9, Project Jigsaw Elek Márton @anzix 2015 March DPC Consulting
  • 2. Java 9 roadmap 2015/09/08 Mark Reinhold: The state of the module system (Java 9 b83) 2015/12/10 Feature Complete 2016/02/04 All Tests Run 2016/02/25 Rampdown Start 2016/04/21 Zero Bug Bounce 2016/06/16 Rampdown Phase 2 2016/07/21 Final Release Candidate 2016/09/22 General Availability
  • 4. Improvements ● Java REPL ● HTTP2 Client ● UTF-8 Property files ● Microbenchmark Suite ● Compiler improvements ● Money and Currency API, JSR-354 (?) ● JSON API (? - proposed to be dropped) ● ProcessAPI update (pid, process list) ● HTML5 Javadoc ● Make G1 the default GC algorithm ● Remove deprecated GC combinations
  • 6. Related JEPs/JSR JEP 200: The Modular JDK JEP 201: Modular Source Code JEP 220: Modular Run-Time Images JEP 162: Prepare for Modularization (Java8) JSR 376: Java Platform Module System Good source: Mark Reinhold: The state of the module system
  • 7. Getting started Create your first module: ● traditional JAR file with ● module-info.java module hu.dpc.java9.logger { }
  • 8. Compile the module ● Could be compiled with standard tools (maven) if there are no dependencies ● Command line tools are also changed javac -d /tmp/modules/hu.dpc.java9.logger -modulepath /tmp/modules -sourcepath src/main/java …..java
  • 9. Using the logger Create your first module: ● traditional JAR file with ● module-info.java module hu.dpc.java9.logger { exports hu.dpc.java9.logger; }
  • 10. Using logger public class App { public static void main(String[] args) LoggerFactory.getLogger().log("Hello world"); } } module hu.dpc.java9.app { requires hu.dpc.java9.logger; }
  • 11. Package level dependencies Source: M Reinhold: The state of the module system
  • 12. Why we need classloaders? ● Classloader is for creating new classes ● Reference to a class could be used even without explicit export LoggerImpl App LoggerFactory Logger exports requires
  • 13. Compile and run javac -d /tmp/modules/hu.dpc.java9.logger -modulepath /tmp/modules -sourcepath src/main/java ....java java -mp /tmp/modules -m hu.dpc.java9.app/hu.dpc.java9.App
  • 14. Backward compatibility java -mp /tmp/modules -m hu.dpc.java9.app/hu.dpc.java9.App java -cp /tmp/modules/hu.dpc.java9.app:/tmp/modules/hu.dpc.java9.logger hu.dpc.java9.App
  • 15. Packaging: jmod ● Accommodate native code, configuration files, and other kinds of data ● "Whether this new format, provisionally named “JMOD,” should be standardized is an open question."
  • 16. JDK modules ● Most of the APIs are modularized ● can’t be used without proper requires in module-info
  • 20. Service Layer - Java 6-8 Service Provider Interface ● Which are the implementation of a specific interface? ServiceLoader<Logger> loggers = ServiceLoader.load(Logger.class); for (Logger logger: loggers) { logger.log("hello world"); } }
  • 21. Service Layer - Java 6-8 ServiceLoader<Logger> loggers = ServiceLoader.load(Logger.class); for (Logger logger: loggers) { logger.log("hello world"); } } Definition (in the jar file): META-INF/services/hu.dpc.java9.logger.Logger hu.dpc.java9.logger.internal.LoggerImpl
  • 22. Service Layer - Java 6-8 logger-framework.jar logger-mysql.jar interface Logger{...} class MysqlLogger{...} class LoggerFactory{...
  • 23. Service Layer - Java 9 Usage: ServiceLoader<Logger> loggers = ServiceLoader.load(Logger.class); for (Logger logger: loggers) { logger.log("hello world"); } }
  • 24. Definition In the hu.dpc.java9.logger module: module hu.dpc.java9.logger { exports hu.dpc.java9.logger; provides hu.dpc.java9.logger.Logger with hu.dpc.java9.logger.internal.LoggerImpl; } In the hu.dpc.java9.app module module hu.dpc.java9.app { requires hu.dpc.java9.logger; use hu.dpc.java9.logger.Logger; }
  • 25. Non requirements ● Modularize the Java Language Specification ● Modularize the Java Virtual Machine Specification ● Multiple versions ● Version selection ● Strict classloader requirements See: http://openjdk.java.net/projects/jigsaw/spec/reqs/
  • 26. Java 9 vs OSGi Java 9 / Jigsaw OSGi metadata module-info.java (nincs meta adat) META-INF classpath separation exports/requires Import-Package/Export-Package classpath++ transitive imports, fragment bundle/dynamic import classloader hierarchy ClassLoader: unspecified strict, per bundle service layer static (get implementations) dynamic (get implemetations + start/stop listeners) services interface + implementation for the standard services (logging, config...) versioning no yes
  • 27. Summary/Future ● Summary – classpath separation: private/public – service locator (based on existing SPI) – modularized JVM APIs ● Not scope – versioning! – strict class loader rules ● Shoud be upgraded: – all the IDEs – all the build tools (maven, gradle) – all the JVM based languages (Scala, Clojure) ● SPI – could be more widely adopted