SlideShare una empresa de Scribd logo
1 de 26
Descargar para leer sin conexión
OSGi and Java 9+ BJ Hargrave, IBM
Java 9 introduced the Java Platform Module System (JPMS)
• JPMS was primarily added to Java to enable modularization of the Java
platform
• Internals can be encapsulated to avoid dependencies - sun.misc.Unsafe
• Platform can be safely subset - jlink
• But JPMS can also be used by application code running on the platform
• But migration from plain JAR to module is a huge challenge
• It really depends on the bottom level dependencies going first
But JPMS really falls short for general use in applications
• The Java platform is a single code base, so all the modules are built together
and releases together
• Applications are almost never like this, they are composed of many modules
• From many sources including open source projects
• Released individually on their own schedules
• Potential for version conflicts in shared dependencies
Main Shortfalls
• Isolation - JPMS uses a single class loader per layer by default. So your non-exported
(private) packages can conflict with someone else’s non-exported (private) packages:
shadowing.
• Identity dependency - Modules depend upon the names of other module not things used
at runtime: classes in packages. So module names are API. As are transitive requirements
• Access restrictions - Reflection is not allowed unless you “open” your module. This is a
challenge for dependency injection and annotation scanning. You often don’t and
shouldn’t know the name of the module which needs to reflect upon you nor should you
put code, which needs reflection, in exported packages.
• Versioning - ??? Someone else’s problem. Like yours!
Java 9+ support in OSGi Core R7
Changes in Core R7 for Java 9+
• Multi-Release JARs (MRJAR)
• Runtime discovery of platform packages
• Bundle can import java.* packages
• Backwards compatible with pre-Java 9 and past releases of OSGi Core
Multi-Release JARs (MRJAR)
• A MRJAR file allows for a single JAR to support multiple major versions of the Java platform
• For example, a MRJAR file can depend on both the Java 8 and Java 9 major platform releases,
where some class files depend on APIs from Java 8 and other class file depend on APIs added
in Java 9
• The purpose is to support alternative implementations of select classes to deal with changes in the
visible APIs of the Java platform
• It is not meant as a means to supply new function or new API on different Java platform versions
• Only supported on Java 9 and above
• Multi-Release: true
MRJAR example
META-INF/MANIFEST.MF
com/example/foo/Bar.class
com/example/foo/bar.properties
META-INF/versions/9/com/example/foo/Bar.class
META-INF/versions/10/com/example/foo/bar.properties
META-INF/versions/11/com/example/foo/Bar.class
MRJAR Java 8 effective content
META-INF/MANIFEST.MF
com/example/foo/Bar.class
com/example/foo/bar.properties
META-INF/versions/9/com/example/foo/Bar.class
META-INF/versions/10/com/example/foo/bar.properties
META-INF/versions/11/com/example/foo/Bar.class
MRJAR Java 9 effective content
META-INF/MANIFEST.MF
com/example/foo/Bar.class
com/example/foo/bar.properties
META-INF/versions/9/com/example/foo/Bar.class
META-INF/versions/10/com/example/foo/bar.properties
META-INF/versions/11/com/example/foo/Bar.class
MRJAR Java 10 effective content
META-INF/MANIFEST.MF
com/example/foo/Bar.class
com/example/foo/bar.properties
META-INF/versions/9/com/example/foo/Bar.class
META-INF/versions/10/com/example/foo/bar.properties
META-INF/versions/11/com/example/foo/Bar.class
MRJAR Java 11 effective content
META-INF/MANIFEST.MF
com/example/foo/Bar.class
com/example/foo/bar.properties
META-INF/versions/9/com/example/foo/Bar.class
META-INF/versions/10/com/example/foo/bar.properties
META-INF/versions/11/com/example/foo/Bar.class
Multi-Release Bundles
• A bundle can be a multi-release bundle when it has Multi-Release: true in its manifest
• When a bundle is multi-release, the framework must look for the presence of a supplemental manifest
in a versioned folder of the bundle
• META-INF/versions/9/OSGI-INF/MANIFEST.MF
• The supplemental manifest, from the highest versioned folder, can contain Import-Package and
Require-Capability headers which replace the headers from the main manifest
• Since the alternate class implementations in the versioned folder can require different dependencies
• As a best practice, a supplemental manifest should not contain additional requirements on
capabilities which are not supplied by the Java platform for the Java version associated with the
supplemental manifest
Multi-Release Containers
• In additional to the bundle itself, a bundle’s class path can specify multiple
containers and each container can also be multi-release
• Bundle-ClassPath: ., libs/foo.jar
• A container must have Multi-Release: true in its manifest to be
recognized as a multi-release container
• When a container is a multi-release container, the framework must look in the
versioned folders when attempting to locate a class or resource in the
container
Runtime discovery of platform packages
• Now that the Java platform is modularized, the platform can be configured to
load only certain modules
• You can have a smaller, custom runtime that is tailored to the needs of a
specific application => jlink
• So the set of java.* packages provide by the running Java platform is no
longer constant for a specific version of the Java platform!
• So R7 frameworks must ask the platform for the current set of java.*
packages and use that to set the
org.osgi.framework.system.packages property
Importing java.* packages
• Bundle have used a requirement on the osgi.ee capability as a proxy for the set of java.*
packages they may require
• Given that the set of available java.* packages can vary, the osgi.ee requirement can
now only be used to express the JVM requirement
• e.g. Java 10 class file support needed
• Bundles are now permitted to list java.* packages in their Import-Package
• This can be used by the framework to resolve the bundle to ensure their java.* package
requirements can be met
• But class loading for java.* packages is still the same: parent delegation
Experiments
Credit
• Tom Watson is the mad genius behind these OSGi experiments with JPMS
• So all credit goes to Tom
• I am just reporting on them
“OSGi Sandwich” - https://github.com/tjwatson/osgi-jpms-layer
Java Module Layers and OSGi Bundles: First Try
Java Module Layers and OSGi Bundles: Second Try
Atomos - https://github.com/tjwatson/atomos
Tools
Tooling
• Bnd support
• MRJARs
• Import java.* packages when targeting Core R7
• Make jars that are bundles and modules?
• Automatic enrichment of module-info based upon annotations?
• Shading non-exported packages?
Thanks!
Evaluate the Sessions
-1 0 +1
Sign in and vote at eclipsecon.org

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

Tampere Technical University - Seminar Presentation in testind day 2016 - Sca...
Tampere Technical University - Seminar Presentation in testind day 2016 - Sca...Tampere Technical University - Seminar Presentation in testind day 2016 - Sca...
Tampere Technical University - Seminar Presentation in testind day 2016 - Sca...
 
Dependency management in Xcode 11
Dependency management in Xcode 11Dependency management in Xcode 11
Dependency management in Xcode 11
 
Platform without vendor lock-in
Platform without vendor lock-inPlatform without vendor lock-in
Platform without vendor lock-in
 
OSGi Enterprise Expert Group (OSGi Users Forum Germany)
OSGi Enterprise Expert Group (OSGi Users Forum Germany)OSGi Enterprise Expert Group (OSGi Users Forum Germany)
OSGi Enterprise Expert Group (OSGi Users Forum Germany)
 
Implementing portlets using Web Scripts
Implementing portlets using Web ScriptsImplementing portlets using Web Scripts
Implementing portlets using Web Scripts
 
.Net Core
.Net Core.Net Core
.Net Core
 
Alfresco Summit 2014 - Crafter CMS - Case European Bank
Alfresco Summit 2014 - Crafter CMS - Case European BankAlfresco Summit 2014 - Crafter CMS - Case European Bank
Alfresco Summit 2014 - Crafter CMS - Case European Bank
 
Guided overview of software frameworks qt framework
Guided overview of software frameworks   qt frameworkGuided overview of software frameworks   qt framework
Guided overview of software frameworks qt framework
 
20171027 モニタリング勉強会
20171027 モニタリング勉強会20171027 モニタリング勉強会
20171027 モニタリング勉強会
 
.Net standard 2.0
.Net standard 2.0.Net standard 2.0
.Net standard 2.0
 
Oslo Vancouver Project Update
Oslo Vancouver Project UpdateOslo Vancouver Project Update
Oslo Vancouver Project Update
 
Production ready Vert.x
Production ready Vert.xProduction ready Vert.x
Production ready Vert.x
 
Ruby on rails
Ruby on railsRuby on rails
Ruby on rails
 
OpenCms Days 2014 - OpenCms cloud setup with the FI-TS
OpenCms Days 2014 - OpenCms cloud setup with the FI-TSOpenCms Days 2014 - OpenCms cloud setup with the FI-TS
OpenCms Days 2014 - OpenCms cloud setup with the FI-TS
 
Disaster recovery solution with open nebula and storpool
Disaster recovery solution with open nebula and storpoolDisaster recovery solution with open nebula and storpool
Disaster recovery solution with open nebula and storpool
 
São Paulo MuleSoft Meetup - Deployments Models
São Paulo MuleSoft Meetup - Deployments ModelsSão Paulo MuleSoft Meetup - Deployments Models
São Paulo MuleSoft Meetup - Deployments Models
 
Persistent Storage in Openshift using GlusterFS
Persistent Storage in Openshift using GlusterFSPersistent Storage in Openshift using GlusterFS
Persistent Storage in Openshift using GlusterFS
 
OSDC 2017 - Dr. Udo Seidel - VMwares (open source) Way of Container
OSDC 2017 - Dr. Udo Seidel - VMwares (open source) Way of ContainerOSDC 2017 - Dr. Udo Seidel - VMwares (open source) Way of Container
OSDC 2017 - Dr. Udo Seidel - VMwares (open source) Way of Container
 
Drupal
DrupalDrupal
Drupal
 
oVirt 3.6 Deep Dive: Refresh LUN size
oVirt 3.6 Deep Dive: Refresh LUN sizeoVirt 3.6 Deep Dive: Refresh LUN size
oVirt 3.6 Deep Dive: Refresh LUN size
 

Similar a OSGi and Java 9+ - BJ Hargrave (IBM)

Jax london 2011
Jax london 2011Jax london 2011
Jax london 2011
njbartlett
 
Enterprise OSGi at eBay
Enterprise OSGi at eBayEnterprise OSGi at eBay
Enterprise OSGi at eBay
Tony Ng
 

Similar a OSGi and Java 9+ - BJ Hargrave (IBM) (20)

Java Core | Java 8 and OSGi Modularisation | Tim Ellison & Neil Bartlett
Java Core | Java 8 and OSGi Modularisation | Tim Ellison & Neil BartlettJava Core | Java 8 and OSGi Modularisation | Tim Ellison & Neil Bartlett
Java Core | Java 8 and OSGi Modularisation | Tim Ellison & Neil Bartlett
 
Jax london 2011
Jax london 2011Jax london 2011
Jax london 2011
 
Java Platform Module System
Java Platform Module SystemJava Platform Module System
Java Platform Module System
 
OpenJDK Penrose Presentation (JavaOne 2012)
OpenJDK Penrose Presentation (JavaOne 2012)OpenJDK Penrose Presentation (JavaOne 2012)
OpenJDK Penrose Presentation (JavaOne 2012)
 
Create *real* modular Java applications - a brief introduction -
Create *real* modular Java applications - a brief introduction -Create *real* modular Java applications - a brief introduction -
Create *real* modular Java applications - a brief introduction -
 
Introduction to OSGi - Part-1
Introduction to OSGi - Part-1Introduction to OSGi - Part-1
Introduction to OSGi - Part-1
 
Preparing for java 9 modules upload
Preparing for java 9 modules uploadPreparing for java 9 modules upload
Preparing for java 9 modules upload
 
OSGi & Blueprint
OSGi & BlueprintOSGi & Blueprint
OSGi & Blueprint
 
perl-java
perl-javaperl-java
perl-java
 
perl-java
perl-javaperl-java
perl-java
 
Enterprise OSGi at eBay
Enterprise OSGi at eBayEnterprise OSGi at eBay
Enterprise OSGi at eBay
 
Modularity of the Java Platform (OSGi, Jigsaw and Penrose)
Modularity of the Java Platform (OSGi, Jigsaw and Penrose)Modularity of the Java Platform (OSGi, Jigsaw and Penrose)
Modularity of the Java Platform (OSGi, Jigsaw and Penrose)
 
Apache maven and its impact on java 9 (Java One 2017)
Apache maven and its impact on java 9 (Java One 2017)Apache maven and its impact on java 9 (Java One 2017)
Apache maven and its impact on java 9 (Java One 2017)
 
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)
 
What’s expected in Java 9
What’s expected in Java 9What’s expected in Java 9
What’s expected in Java 9
 
Leaner microservices with Java 10
Leaner microservices with Java 10Leaner microservices with Java 10
Leaner microservices with Java 10
 
Java 9, JShell, and Modularity
Java 9, JShell, and ModularityJava 9, JShell, and Modularity
Java 9, JShell, and Modularity
 
Building modular applications with the Java Platform Module System and Layrry
Building modular applications with the Java Platform Module System and LayrryBuilding modular applications with the Java Platform Module System and Layrry
Building modular applications with the Java Platform Module System and Layrry
 
Modules in Java? Finally! (OpenJDK 9 Jigsaw, JSR376)
Modules in Java? Finally! (OpenJDK 9 Jigsaw, JSR376)Modules in Java? Finally! (OpenJDK 9 Jigsaw, JSR376)
Modules in Java? Finally! (OpenJDK 9 Jigsaw, JSR376)
 
Java modules
Java modulesJava modules
Java modules
 

Más de mfrancis

Migrating from PDE to Bndtools in Practice - Amit Kumar Mondal (Deutsche Tele...
Migrating from PDE to Bndtools in Practice - Amit Kumar Mondal (Deutsche Tele...Migrating from PDE to Bndtools in Practice - Amit Kumar Mondal (Deutsche Tele...
Migrating from PDE to Bndtools in Practice - Amit Kumar Mondal (Deutsche Tele...
mfrancis
 
How OSGi drives cross-sector energy management - Jörn Tümmler (SMA Solar Tech...
How OSGi drives cross-sector energy management - Jörn Tümmler (SMA Solar Tech...How OSGi drives cross-sector energy management - Jörn Tümmler (SMA Solar Tech...
How OSGi drives cross-sector energy management - Jörn Tümmler (SMA Solar Tech...
mfrancis
 
Improved developer productivity thanks to Maven and OSGi - Lukasz Dywicki (Co...
Improved developer productivity thanks to Maven and OSGi - Lukasz Dywicki (Co...Improved developer productivity thanks to Maven and OSGi - Lukasz Dywicki (Co...
Improved developer productivity thanks to Maven and OSGi - Lukasz Dywicki (Co...
mfrancis
 
Prototyping IoT systems with a hybrid OSGi & Node-RED platform - Bruce Jackso...
Prototyping IoT systems with a hybrid OSGi & Node-RED platform - Bruce Jackso...Prototyping IoT systems with a hybrid OSGi & Node-RED platform - Bruce Jackso...
Prototyping IoT systems with a hybrid OSGi & Node-RED platform - Bruce Jackso...
mfrancis
 
Visualization of OSGi based Software Architectures in Virtual Reality - Lisa ...
Visualization of OSGi based Software Architectures in Virtual Reality - Lisa ...Visualization of OSGi based Software Architectures in Virtual Reality - Lisa ...
Visualization of OSGi based Software Architectures in Virtual Reality - Lisa ...
mfrancis
 

Más de mfrancis (20)

Eclipse Modeling Framework and plain OSGi the easy way - Mark Hoffman (Data I...
Eclipse Modeling Framework and plain OSGi the easy way - Mark Hoffman (Data I...Eclipse Modeling Framework and plain OSGi the easy way - Mark Hoffman (Data I...
Eclipse Modeling Framework and plain OSGi the easy way - Mark Hoffman (Data I...
 
Simplify Web UX Coding using OSGi Modularity Magic - Paul Fraser (A2Z Living)
Simplify Web UX Coding using OSGi Modularity Magic - Paul Fraser (A2Z Living)Simplify Web UX Coding using OSGi Modularity Magic - Paul Fraser (A2Z Living)
Simplify Web UX Coding using OSGi Modularity Magic - Paul Fraser (A2Z Living)
 
OSGi for the data centre - Connecting OSGi to Kubernetes - Frank Lyaruu
OSGi for the data centre - Connecting OSGi to Kubernetes - Frank LyaruuOSGi for the data centre - Connecting OSGi to Kubernetes - Frank Lyaruu
OSGi for the data centre - Connecting OSGi to Kubernetes - Frank Lyaruu
 
OSGi Feature Model - Where Art Thou - David Bosschaert (Adobe)
OSGi Feature Model - Where Art Thou - David Bosschaert (Adobe)OSGi Feature Model - Where Art Thou - David Bosschaert (Adobe)
OSGi Feature Model - Where Art Thou - David Bosschaert (Adobe)
 
Migrating from PDE to Bndtools in Practice - Amit Kumar Mondal (Deutsche Tele...
Migrating from PDE to Bndtools in Practice - Amit Kumar Mondal (Deutsche Tele...Migrating from PDE to Bndtools in Practice - Amit Kumar Mondal (Deutsche Tele...
Migrating from PDE to Bndtools in Practice - Amit Kumar Mondal (Deutsche Tele...
 
OSGi CDI Integration Specification - Ray Augé (Liferay)
OSGi CDI Integration Specification - Ray Augé (Liferay)OSGi CDI Integration Specification - Ray Augé (Liferay)
OSGi CDI Integration Specification - Ray Augé (Liferay)
 
How OSGi drives cross-sector energy management - Jörn Tümmler (SMA Solar Tech...
How OSGi drives cross-sector energy management - Jörn Tümmler (SMA Solar Tech...How OSGi drives cross-sector energy management - Jörn Tümmler (SMA Solar Tech...
How OSGi drives cross-sector energy management - Jörn Tümmler (SMA Solar Tech...
 
Improved developer productivity thanks to Maven and OSGi - Lukasz Dywicki (Co...
Improved developer productivity thanks to Maven and OSGi - Lukasz Dywicki (Co...Improved developer productivity thanks to Maven and OSGi - Lukasz Dywicki (Co...
Improved developer productivity thanks to Maven and OSGi - Lukasz Dywicki (Co...
 
It Was Twenty Years Ago Today - Building an OSGi based Smart Home System - Ch...
It Was Twenty Years Ago Today - Building an OSGi based Smart Home System - Ch...It Was Twenty Years Ago Today - Building an OSGi based Smart Home System - Ch...
It Was Twenty Years Ago Today - Building an OSGi based Smart Home System - Ch...
 
Popular patterns revisited on OSGi - Christian Schneider (Adobe)
Popular patterns revisited on OSGi - Christian Schneider (Adobe)Popular patterns revisited on OSGi - Christian Schneider (Adobe)
Popular patterns revisited on OSGi - Christian Schneider (Adobe)
 
Integrating SLF4J and the new OSGi LogService 1.4 - BJ Hargrave (IBM)
Integrating SLF4J and the new OSGi LogService 1.4 - BJ Hargrave (IBM)Integrating SLF4J and the new OSGi LogService 1.4 - BJ Hargrave (IBM)
Integrating SLF4J and the new OSGi LogService 1.4 - BJ Hargrave (IBM)
 
OSG(a)i: because AI needs a runtime - Tim Verbelen (imec)
OSG(a)i: because AI needs a runtime - Tim Verbelen (imec)OSG(a)i: because AI needs a runtime - Tim Verbelen (imec)
OSG(a)i: because AI needs a runtime - Tim Verbelen (imec)
 
Flying to Jupiter with OSGi - Tony Walsh (ESA) & Hristo Indzhov (Telespazio V...
Flying to Jupiter with OSGi - Tony Walsh (ESA) & Hristo Indzhov (Telespazio V...Flying to Jupiter with OSGi - Tony Walsh (ESA) & Hristo Indzhov (Telespazio V...
Flying to Jupiter with OSGi - Tony Walsh (ESA) & Hristo Indzhov (Telespazio V...
 
MicroProfile, OSGi was meant for this - Ray Auge (Liferay)
MicroProfile, OSGi was meant for this - Ray Auge (Liferay)MicroProfile, OSGi was meant for this - Ray Auge (Liferay)
MicroProfile, OSGi was meant for this - Ray Auge (Liferay)
 
Prototyping IoT systems with a hybrid OSGi & Node-RED platform - Bruce Jackso...
Prototyping IoT systems with a hybrid OSGi & Node-RED platform - Bruce Jackso...Prototyping IoT systems with a hybrid OSGi & Node-RED platform - Bruce Jackso...
Prototyping IoT systems with a hybrid OSGi & Node-RED platform - Bruce Jackso...
 
How to connect your OSGi application - Dirk Fauth (Bosch)
How to connect your OSGi application - Dirk Fauth (Bosch)How to connect your OSGi application - Dirk Fauth (Bosch)
How to connect your OSGi application - Dirk Fauth (Bosch)
 
Visualization of OSGi based Software Architectures in Virtual Reality - Lisa ...
Visualization of OSGi based Software Architectures in Virtual Reality - Lisa ...Visualization of OSGi based Software Architectures in Virtual Reality - Lisa ...
Visualization of OSGi based Software Architectures in Virtual Reality - Lisa ...
 
Turtles all the Way Up – From OSGi bundles to Fog Computing - Tim Ward (Paremus)
Turtles all the Way Up – From OSGi bundles to Fog Computing - Tim Ward (Paremus)Turtles all the Way Up – From OSGi bundles to Fog Computing - Tim Ward (Paremus)
Turtles all the Way Up – From OSGi bundles to Fog Computing - Tim Ward (Paremus)
 
OSGi in Action - How we use OSGi to build Open Liberty - Alasdair Nottingham ...
OSGi in Action - How we use OSGi to build Open Liberty - Alasdair Nottingham ...OSGi in Action - How we use OSGi to build Open Liberty - Alasdair Nottingham ...
OSGi in Action - How we use OSGi to build Open Liberty - Alasdair Nottingham ...
 
Software AG Application Modularity - OSGi and JPMS (Jigsaw)
Software AG Application Modularity - OSGi and JPMS (Jigsaw)Software AG Application Modularity - OSGi and JPMS (Jigsaw)
Software AG Application Modularity - OSGi and JPMS (Jigsaw)
 

Último

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
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
 
+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@
 

Último (20)

Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
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
 
+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...
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
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
 
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
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 

OSGi and Java 9+ - BJ Hargrave (IBM)

  • 1. OSGi and Java 9+ BJ Hargrave, IBM
  • 2. Java 9 introduced the Java Platform Module System (JPMS) • JPMS was primarily added to Java to enable modularization of the Java platform • Internals can be encapsulated to avoid dependencies - sun.misc.Unsafe • Platform can be safely subset - jlink • But JPMS can also be used by application code running on the platform • But migration from plain JAR to module is a huge challenge • It really depends on the bottom level dependencies going first
  • 3. But JPMS really falls short for general use in applications • The Java platform is a single code base, so all the modules are built together and releases together • Applications are almost never like this, they are composed of many modules • From many sources including open source projects • Released individually on their own schedules • Potential for version conflicts in shared dependencies
  • 4. Main Shortfalls • Isolation - JPMS uses a single class loader per layer by default. So your non-exported (private) packages can conflict with someone else’s non-exported (private) packages: shadowing. • Identity dependency - Modules depend upon the names of other module not things used at runtime: classes in packages. So module names are API. As are transitive requirements • Access restrictions - Reflection is not allowed unless you “open” your module. This is a challenge for dependency injection and annotation scanning. You often don’t and shouldn’t know the name of the module which needs to reflect upon you nor should you put code, which needs reflection, in exported packages. • Versioning - ??? Someone else’s problem. Like yours!
  • 5. Java 9+ support in OSGi Core R7
  • 6. Changes in Core R7 for Java 9+ • Multi-Release JARs (MRJAR) • Runtime discovery of platform packages • Bundle can import java.* packages • Backwards compatible with pre-Java 9 and past releases of OSGi Core
  • 7. Multi-Release JARs (MRJAR) • A MRJAR file allows for a single JAR to support multiple major versions of the Java platform • For example, a MRJAR file can depend on both the Java 8 and Java 9 major platform releases, where some class files depend on APIs from Java 8 and other class file depend on APIs added in Java 9 • The purpose is to support alternative implementations of select classes to deal with changes in the visible APIs of the Java platform • It is not meant as a means to supply new function or new API on different Java platform versions • Only supported on Java 9 and above • Multi-Release: true
  • 9. MRJAR Java 8 effective content META-INF/MANIFEST.MF com/example/foo/Bar.class com/example/foo/bar.properties META-INF/versions/9/com/example/foo/Bar.class META-INF/versions/10/com/example/foo/bar.properties META-INF/versions/11/com/example/foo/Bar.class
  • 10. MRJAR Java 9 effective content META-INF/MANIFEST.MF com/example/foo/Bar.class com/example/foo/bar.properties META-INF/versions/9/com/example/foo/Bar.class META-INF/versions/10/com/example/foo/bar.properties META-INF/versions/11/com/example/foo/Bar.class
  • 11. MRJAR Java 10 effective content META-INF/MANIFEST.MF com/example/foo/Bar.class com/example/foo/bar.properties META-INF/versions/9/com/example/foo/Bar.class META-INF/versions/10/com/example/foo/bar.properties META-INF/versions/11/com/example/foo/Bar.class
  • 12. MRJAR Java 11 effective content META-INF/MANIFEST.MF com/example/foo/Bar.class com/example/foo/bar.properties META-INF/versions/9/com/example/foo/Bar.class META-INF/versions/10/com/example/foo/bar.properties META-INF/versions/11/com/example/foo/Bar.class
  • 13. Multi-Release Bundles • A bundle can be a multi-release bundle when it has Multi-Release: true in its manifest • When a bundle is multi-release, the framework must look for the presence of a supplemental manifest in a versioned folder of the bundle • META-INF/versions/9/OSGI-INF/MANIFEST.MF • The supplemental manifest, from the highest versioned folder, can contain Import-Package and Require-Capability headers which replace the headers from the main manifest • Since the alternate class implementations in the versioned folder can require different dependencies • As a best practice, a supplemental manifest should not contain additional requirements on capabilities which are not supplied by the Java platform for the Java version associated with the supplemental manifest
  • 14. Multi-Release Containers • In additional to the bundle itself, a bundle’s class path can specify multiple containers and each container can also be multi-release • Bundle-ClassPath: ., libs/foo.jar • A container must have Multi-Release: true in its manifest to be recognized as a multi-release container • When a container is a multi-release container, the framework must look in the versioned folders when attempting to locate a class or resource in the container
  • 15. Runtime discovery of platform packages • Now that the Java platform is modularized, the platform can be configured to load only certain modules • You can have a smaller, custom runtime that is tailored to the needs of a specific application => jlink • So the set of java.* packages provide by the running Java platform is no longer constant for a specific version of the Java platform! • So R7 frameworks must ask the platform for the current set of java.* packages and use that to set the org.osgi.framework.system.packages property
  • 16. Importing java.* packages • Bundle have used a requirement on the osgi.ee capability as a proxy for the set of java.* packages they may require • Given that the set of available java.* packages can vary, the osgi.ee requirement can now only be used to express the JVM requirement • e.g. Java 10 class file support needed • Bundles are now permitted to list java.* packages in their Import-Package • This can be used by the framework to resolve the bundle to ensure their java.* package requirements can be met • But class loading for java.* packages is still the same: parent delegation
  • 18. Credit • Tom Watson is the mad genius behind these OSGi experiments with JPMS • So all credit goes to Tom • I am just reporting on them
  • 19. “OSGi Sandwich” - https://github.com/tjwatson/osgi-jpms-layer
  • 20. Java Module Layers and OSGi Bundles: First Try
  • 21. Java Module Layers and OSGi Bundles: Second Try
  • 23. Tools
  • 24. Tooling • Bnd support • MRJARs • Import java.* packages when targeting Core R7 • Make jars that are bundles and modules? • Automatic enrichment of module-info based upon annotations? • Shading non-exported packages?
  • 26. Evaluate the Sessions -1 0 +1 Sign in and vote at eclipsecon.org