SlideShare une entreprise Scribd logo
1  sur  40
Télécharger pour lire hors ligne
Java 8 and OSGi modularization
      Tim Ellison, IBM UK Labs
      Neil Bartlett, Paremus Ltd
What is a module?
      Why do we need a module system?

    • Modules facilitate software engineering & enhanced runtime capabilities
        – Decomposition of complex systems
        – Software assemblies of pre-built modules
        – Provisioning / deployment, including module repositories
        – Versioning and configuration management


    • The module system is used to manage the modules, including installing,
      activating, resolving module requirements and conflicts.


    • Interacting with the module system provides a higher level abstraction than
      the language provides directly.



2
Modules in Java
    • The module as a unit of encapsulation...


    • The Java language already has two kinds of module: classes and packages.
       – classes encapsulate fields and methods
        – packages encapsulate classes and resources


    • Problem: neither of these is a deployable unit (too granular, too tightly
      coupled).


    • Java's unit of deployment is the JAR file.
       – No encapsulation, therefore not a module!


    • Problem: need an entity that is a deployable unit of encapsulation.
3
Desirable characteristics of a module

    •   A module should be highly coherent.


    •   A module should be loosely coupled to other modules.


    •   A module should be explicit about what it provides to other modules.


    •   A module should be explicit about what it depends on from other
        modules.




4
Why modules for the Java runtime (JRE)?
    • Presently the JRE is a monolithic entity
        – in general the runtime must assume your application will use anything and everything
        – class loaders provide runtime type definition and isolation
        – download time and start-up time are directly impacted by the number of types available in
          the runtime


    • Application start-up time includes a linear search through the class path to
      find system and application code
        – e.g. Oracle 1.7 Windows bootclass path contains nearly 20k classes
        –   resources.jar    rt.jar   jsse.jar    jce.jar    charsets.jar
        – rt.jar index alone is ~1Mb


    • To the JRE, your application's jars’ indexes are disjoint & unsorted
        – there are JRE implementation 'tricks' like look aside tables and shared classes that can
          help
        – class loading is a BIG time hog to amortize over the length of the run

5
Why modules for the Java runtime (JRE)? - cont.
    • Dependency management
        – avoid “JAR hell” → trying satisfy competing requirements by simple path ordering
        – type name space comprising (unversioned) package name is often insufficient
        – e.g. my app depends upon foo-v2.jar and bar-v2.jar
          but foo-v2.jar depends upon bar-v1.jar
            -classpath foo-v2.jar; bar-v2.jar; bar-v1.jar –> my app “wins”
            -classpath foo-v2.jar; bar-v1.jar; bar-v2.jar –> foo “wins”



    • Module level visibility
        – public, protected, private and package-private level visibility means some
          implementation types (com.sun.) need to be marked public to be called by java. APIs.
        – convention asks people not to depend upon them...
        –
    • Version control
        – ability to define the compatibility of a module based on numbering scheme
        – different module versions for different target devices / resource goals

6
Introducing Project Jigsaw

    •    Project Jigsaw is an effort at OpenJDK
          – defining a simple module system for Java
          – modularizing the JRE itself
          – originally intended as an implementation detail for the JRE / applications, but being
            adopted as a Java standard (JSR)


    •    Working within constraints of backwards compatibility
          – existing Java APIs “cannot” be changed
          – Some packages contain wildly different functionality
            e.g. java.util contains collection hierarchy and Locale infrastructure


    •    Introduces language changes to define modules
             src/com/example/myclass.java
             src/com/example/myclassimpl.java
             src/module-info.java                                 module com.example @ 1.0 {
                                                                       requires jdk.base;
                                                                       requires foo @ 2.0;
                                                                       requires bar @ 2.0;
                                                                  }
7
What about OSGi?

    • Existing, mature, de facto modularity solution for Java applications.


    • Rich modularity model based on code-level (package) dependencies,
      module-level dependencies, and services.


    • First practical solution for effective component reuse
       – well supported by multiple implementations, tooling, etc.


    • Millions use applications built with OSGi
        – most application servers are based on OSGi

                                                       Bundle-ManifestVersion: 2
    • No language changes.                             Bundle-SymbolicName: com.ex.mybundle
                                                       Bundle-Version: 1.0.0
        – defines info in META-INF/MANIFEST.MF         Import-Package: com.example.bar
                                                       Export-Package: com.example.foo
8
Module dependency resolution
    • The module system must resolve bundle dependencies, possibly in the face
      of multiple valid alternatives
        – e.g. my app depends upon (foo-v2.jar and (bar-v1.jar or bar-v2.jar))
          and foo-v2.jar depends upon bar-v1.jar
        – if my app touches bar first, the module system may chose bar-v2.jar
        – if my app touches foo first, the module system will chose bar-v1.jar


    • OSGi's dynamic dependency resolution always finds the best fit for currently
      invoked bundles at runtime
        – Modules are apparent at runtime
        – Runtime activation lifecycle: installed, resolved, starting, active, stopping,
          uninstalled


    • Jigsaw resolves module dependencies during build, installation, or runtime
        – Gives opportunity for load time optimizations such as pre-verify, indexing, etc.

9
OSGi Dependency Model

     • OSGi best practice is to depend on APIs.
     • APIs are defined in terms of packages.
     • Read almost any JSR. It defines the
       package(s) that the JSR specifies, e.g.:
       – JSR 112 → javax.resource.spi, cci
       – JSR 173 → javax.xml.stream
       – JSR 315 → javax.servlet (3.0)



10
OSGi: As Simple As Possible...

     • The primary unit of sharing is the package.
     • Bundle A exports a package
       – Export-Package: api
     • Bundle B imports a package
       – Import-Package: api




11
But No Simpler!

     • Module-to-module dependencies also
       supported
       – Require-Bundle: A
     • Most OSGi devs consider Require-Bundle to
       be deprecated.




12
Refactoring with Import-Package




13
Refactoring with Require-Bundle




14
Import-Package vs Require-Bundle

     • Import-Package directly reflects reality
     • Can be derived straight from the code!
     • Require-Bundle is a parallel dependency
       system => manually maintained, hard to
       statically verify.




15
Don't Split the Packages!

     • In OSGi, the package is king.
     • Import-Package will resolve to exactly one
       export of that package, and this is a good
       thing!!
     • Require-Bundle can be used when
       packages are split for legacy/stupid reasons.




16
More On Split Packages

     • Java packages were never meant to be split
       across deployment units.
     • Even plain Java provides a way to enforce
       this: Sealed Packages.
     • You wouldn't split a method across classes...
       or a class across packages...




17
Handling platform-specific code
        •   The JRE contains many classes and native code that are specific to an
            OS / CPU architecture


        •   “Universal modules”
             – Contain code for all platforms
             – Requires download of unused code, and new revisions that are not relevant


        •   “Platform-specific sub-modules”
             – Put platfom-specific code in a separate module
             – Many of the differences are in the native code only, so requires a native
               module


        •   “Native package”
             – Hooks into the OS packaging system, so that dependencies can be handled
               by the OS (e.g. .deb file)


18
Handling platform-specific code – OSGi style

      • OSGi allows you to deliver platform-specific native code in a bundle
        JAR file.
           Bundle-NativeCode:
           libfoo.so; osname=Linux; processor=x86,
           foo.dll; osname=Windows7; processor=x86


      • The OSGi implementation of ClassLoader#findLibrary(“foo”)
        returns the path to the correct version.


      • Flexibility to structure as a universal module, or sub-module.




                                         http://www.osgi.org/Specifications/Reference
19
Modularising the JRE

     • JRE libraries evolved organically
       (haphazardly!) over 12+ years.
     • Many cyclic dependencies
     • Many weird/unexpected dependencies
     • In particular java.util is an incoherent
       mess (this always happens to general util
       packages!)
     • => Split packages are unavoidable

20
Can We Use OSGi?

     • OSGi does support split packages, through
       Require-Bundle
     • Works, though considered deprecated.
     • But that's not the whole story.




21
Single Boot Classloader Assumption

     • Many parts of the JRE assume a single boot
       classloader.
     • Private package (aka “default”) access
       assumes whole packages are in single
       classloader.
     • Therefore need to split some packages
       across modules but not across classloaders.
       => Need to break 1-to-1 module/classloader
       mapping.
22
But OSGi Supports Classloader Sharing!

     • True, through “fragments”.
     • Fragments share the CL of their “host”.
     • Dependency is in the “wrong” direction, i.e.
       fragment depends on host.
     • Can OSGi be modified to support host-to-
       fragment dependencies?
     • Almost certainly!


23
Refactoring Verboten

     • Normal and best solution: move classes to
       the correct, i.e. most logical package.
     • In the JRE is this impossible!
     • 9 million developers (Sun estimate, 2009)
       and billions of apps depend on this library.




24
Irrelevant Stuff

     • Let's not worry about:
       – Format of metadata
       – Location of metadata
       – Format of deployable modules
     • Differences here are surmountable
     • E.g. OSGi already supports WAR file
       deployment.



25
Less Important Stuff

     • Let's even not worry about versioning right
       now.
     • 3 numeric segments vs 20...
     • Qualifier ordering, snapshots...
     • Again, we can adapt.




26
Jigsaw Dependency Model

     • Modules require other modules by name
       (and optionally, version)

      module B @ 1.0 {
        require A @ [2.0,3.0);
      }




27
Jigsaw Dependency Model

     • Requirements can be “local”.
     • Target module is loaded in same classloader
       as present module.

      module B @ 1.0 {
        require local A @ [2.0,3.0);
      }




28
Jigsaw Dependency Model

     • Modules list their exports: at package and
       type level.
     • May include re-exported contents of
       required modules
       module B @ 1.0 {
         require A @ [2.0,3.0);
         export org.foo.ClassFoo;
         export org.bar.*
       }



29
Jigsaw Dependency Model

     • Modules can restrict which other modules
       are allowed to require them.
     • Compare: “friend classes” in C++.
     • Note that the permit clause is un-versioned.

       module A @ 2.0 {
         permit B;
       }




30
Jigsaw Dependency Model

     • Modules can logically “provide” other
       module names.
     • Compare: “virtual packages” in Debian.
     • Supports substitution, but unclear how it will
       support refactoring (splitting/aggregating).
       module com.ibm.stax @ 1.0 {
         provide jdk.stax @ 2.0;
       }



31
Jigsaw Versions

     • Jigsaw modules will be versioned
     • Module requirements use exact version or a
       range
     • Versions have no semantics besides
       ordering




32
Comparison

     • Whole-module dependencies are the
       biggest difference.
     • Jigsaw will suffer all the same problems
       seen in OSGi with Require-Bundle.
     • E.g. Eclipse Core Runtime refactoring hell.
     • While Jigsaw will achieve JDK modularity it
       will increase developer maintenance burden.


33
Both Are Here to Stay!


     •   Try to get the best of both worlds!


     •   OSGi is established and will continue to be used by millions


     •   Jigsaw is underway and a key component in Java 8 plans (Summer 2013)


     •   It need not be a zero-sum game




34
Project Penrose: Jigsaw / OSGi interop (proposed)

     • Level 0 : toleration
         – ensure that OSGi frameworks continue to run unmodified on a Jigsaw
           enabled runtime
         – creating modules / bundles that have both Jigsaw & OSGi metadata on the
           same JAR


     • Level 1 : interop of module info metadata
         – teach OSGi to read Jigsaw module info
             • mapping Jigsaw metadata into OSGi format for the framework to
               understand, e.g. requires ⇒ Require-Bundle:
         – resolve Jigsaw modules using the OSGi resolver




35
Project Penrose: Jigsaw / OSGi interop (proposed)

     • Level 2 : OSGi implementation exploit of Jigsaw modularity
         – Enhance OSGi to use Jigsaw publication repositories etc.


     • Level 3+ : Full interop
         – A blend of OSGi and Jigsaw cross delegation on module phases




     OSGi support
         It must be demonstrated by prototype to be feasible to modify an OSGi micro-
         kernel such that OSGi bundles running in that kernel can depend upon Java
         modules. The kernel must be able to load Java modules directly and resolve
         them using its own resolver, except for core system modules. Core system
         modules can only be loaded using the module system’s reification API.
         http://openjdk.java.net/projects/jigsaw/doc/draft-java-module-system-requirements-12




36
Project Penrose: results to date
     • Level 0 : toleration
          – ensure that OSGi frameworks continue to run unmodified on a Jigsaw enabled
            runtime
          – creating modules / bundles that have both Jigsaw & OSGi metadata on the
            same JAR


     •   Achievement #1: pass the OSGi tests on a Jigsaw enabled runtime
          – Equinox 3.7 – the OSGi reference implementation
          – OSGi 4.3 Compliance Tests – with minor patch for test case error
          – Windows XP sp3, junit-3.8.2, java6u26, java7-ea-b145


     •   Achievement #2: run a Java application as either OSGi or Jigsaw modules
          – Took Java 2D demo
          – Broke it into multiple functional units, and run the demo as OSGi bundles OR
            Jigsaw modules


37
Project Penrose: next steps
     • Level 1 : interop of module info metadata
          – teach OSGi to read Jigsaw module info
              • mapping Jigsaw metadata into OSGi format for the framework to
                understand, e.g. requires ⇒ Require-Bundle:
          – resolve Jigsaw modules using the OSGi resolver


     •   Goal #0: move the work into a new OpenJDK project


     •   Goal #1: map Jigsaw module metadata to OSGi equivalents
          – discussions of how OSGi shall interpret Jigsaw directives


     •   Goal #2: modify OSGi to use Jigsaw reification APIs
          – load a third-party module from the Jigsaw repository
          – resolve it using the OSGi resolver


38
Advice
     •   Stop using internal APIs and implementation classes
         – You will be broken come Java 8


     •   If you need a modularity story that works before summer 2013 then the
         answer is OSGi
         – OSGi will continue to work beyond Java 7 too so it is the safest option


     •   OSGi has greater expressiveness
         – While you may not need it now, do you want to change system when you
           do need it?


     •   Think about how to interoperate with Jigsaw
         – Be modest in your API usage and we can likely help with a tailored JRE



39
Questions




     • Tim Ellison – t.p.ellison@gmail.com


     • Neil Bartlett – njbartlett@gmail.com




40

Contenu connexe

Tendances

Introduction to OSGi
Introduction to OSGiIntroduction to OSGi
Introduction to OSGipradeepfn
 
What Your Jvm Has Been Trying To Tell You
What Your Jvm Has Been Trying To Tell YouWhat Your Jvm Has Been Trying To Tell You
What Your Jvm Has Been Trying To Tell YouJohn Pape
 
Using the OSGi Application Model on Mobile Devices with CLDC JVM - Dimitar Va...
Using the OSGi Application Model on Mobile Devices with CLDC JVM - Dimitar Va...Using the OSGi Application Model on Mobile Devices with CLDC JVM - Dimitar Va...
Using the OSGi Application Model on Mobile Devices with CLDC JVM - Dimitar Va...mfrancis
 
Java Presentation
Java PresentationJava Presentation
Java PresentationAmr Salah
 
J2EE Struts with Hibernate Framework
J2EE Struts with Hibernate FrameworkJ2EE Struts with Hibernate Framework
J2EE Struts with Hibernate Frameworkmparth
 
Ijaprr vol1-2-13-60-64tejinder
Ijaprr vol1-2-13-60-64tejinderIjaprr vol1-2-13-60-64tejinder
Ijaprr vol1-2-13-60-64tejinderijaprr_editor
 
Enterprise OSGi at eBay
Enterprise OSGi at eBayEnterprise OSGi at eBay
Enterprise OSGi at eBayTony Ng
 
A Java Implementer's Guide to Better Apache Spark Performance
A Java Implementer's Guide to Better Apache Spark PerformanceA Java Implementer's Guide to Better Apache Spark Performance
A Java Implementer's Guide to Better Apache Spark PerformanceTim Ellison
 
Java 9 Modules: The Duke Yet Lives That OSGi Shall Depose
Java 9 Modules: The Duke Yet Lives That OSGi Shall DeposeJava 9 Modules: The Duke Yet Lives That OSGi Shall Depose
Java 9 Modules: The Duke Yet Lives That OSGi Shall DeposeNikita Lipsky
 
Java compilation
Java compilationJava compilation
Java compilationMike Kucera
 
The State of Java under Oracle at JCertif 2011
The State of Java under Oracle at JCertif 2011The State of Java under Oracle at JCertif 2011
The State of Java under Oracle at JCertif 2011Arun Gupta
 

Tendances (20)

Introduction to OSGi
Introduction to OSGiIntroduction to OSGi
Introduction to OSGi
 
Introducing Java 7
Introducing Java 7Introducing Java 7
Introducing Java 7
 
Oracle History #5
Oracle History #5Oracle History #5
Oracle History #5
 
What Your Jvm Has Been Trying To Tell You
What Your Jvm Has Been Trying To Tell YouWhat Your Jvm Has Been Trying To Tell You
What Your Jvm Has Been Trying To Tell You
 
Using the OSGi Application Model on Mobile Devices with CLDC JVM - Dimitar Va...
Using the OSGi Application Model on Mobile Devices with CLDC JVM - Dimitar Va...Using the OSGi Application Model on Mobile Devices with CLDC JVM - Dimitar Va...
Using the OSGi Application Model on Mobile Devices with CLDC JVM - Dimitar Va...
 
Dvm
DvmDvm
Dvm
 
Java Presentation
Java PresentationJava Presentation
Java Presentation
 
J2EE Struts with Hibernate Framework
J2EE Struts with Hibernate FrameworkJ2EE Struts with Hibernate Framework
J2EE Struts with Hibernate Framework
 
Ijaprr vol1-2-13-60-64tejinder
Ijaprr vol1-2-13-60-64tejinderIjaprr vol1-2-13-60-64tejinder
Ijaprr vol1-2-13-60-64tejinder
 
What is-java
What is-javaWhat is-java
What is-java
 
Enterprise OSGi at eBay
Enterprise OSGi at eBayEnterprise OSGi at eBay
Enterprise OSGi at eBay
 
Java
JavaJava
Java
 
Os Lattner
Os LattnerOs Lattner
Os Lattner
 
A Java Implementer's Guide to Better Apache Spark Performance
A Java Implementer's Guide to Better Apache Spark PerformanceA Java Implementer's Guide to Better Apache Spark Performance
A Java Implementer's Guide to Better Apache Spark Performance
 
Java 9 Modules: The Duke Yet Lives That OSGi Shall Depose
Java 9 Modules: The Duke Yet Lives That OSGi Shall DeposeJava 9 Modules: The Duke Yet Lives That OSGi Shall Depose
Java 9 Modules: The Duke Yet Lives That OSGi Shall Depose
 
Java8 - Under the hood
Java8 - Under the hoodJava8 - Under the hood
Java8 - Under the hood
 
Java compilation
Java compilationJava compilation
Java compilation
 
.NET Vs J2EE
.NET Vs J2EE.NET Vs J2EE
.NET Vs J2EE
 
Os Rego
Os RegoOs Rego
Os Rego
 
The State of Java under Oracle at JCertif 2011
The State of Java under Oracle at JCertif 2011The State of Java under Oracle at JCertif 2011
The State of Java under Oracle at JCertif 2011
 

En vedette

Construire un Fitbit-like pour chiens et chats (Devoxx France 21/04/2016)
Construire un Fitbit-like pour chiens et chats (Devoxx France 21/04/2016)Construire un Fitbit-like pour chiens et chats (Devoxx France 21/04/2016)
Construire un Fitbit-like pour chiens et chats (Devoxx France 21/04/2016)Daniel Petisme
 
Getting Started with PTO
Getting Started with PTOGetting Started with PTO
Getting Started with PTOLesliePerlow
 
How I met DevOps Clermont'ech #APIHour 4
How I met DevOps Clermont'ech #APIHour 4 How I met DevOps Clermont'ech #APIHour 4
How I met DevOps Clermont'ech #APIHour 4 Daniel Petisme
 
Scala Days 2011 - Rogue: A Type-Safe DSL for MongoDB
Scala Days 2011 - Rogue: A Type-Safe DSL for MongoDBScala Days 2011 - Rogue: A Type-Safe DSL for MongoDB
Scala Days 2011 - Rogue: A Type-Safe DSL for MongoDBjorgeortiz85
 
Optimizing JavaScript and Dynamic Languages on the JVM
Optimizing JavaScript and Dynamic Languages on the JVMOptimizing JavaScript and Dynamic Languages on the JVM
Optimizing JavaScript and Dynamic Languages on the JVMMarcus Lagergren
 

En vedette (6)

Construire un Fitbit-like pour chiens et chats (Devoxx France 21/04/2016)
Construire un Fitbit-like pour chiens et chats (Devoxx France 21/04/2016)Construire un Fitbit-like pour chiens et chats (Devoxx France 21/04/2016)
Construire un Fitbit-like pour chiens et chats (Devoxx France 21/04/2016)
 
Getting Started with PTO
Getting Started with PTOGetting Started with PTO
Getting Started with PTO
 
How I met DevOps Clermont'ech #APIHour 4
How I met DevOps Clermont'ech #APIHour 4 How I met DevOps Clermont'ech #APIHour 4
How I met DevOps Clermont'ech #APIHour 4
 
Pimp My Java LavaJUG
Pimp My Java LavaJUGPimp My Java LavaJUG
Pimp My Java LavaJUG
 
Scala Days 2011 - Rogue: A Type-Safe DSL for MongoDB
Scala Days 2011 - Rogue: A Type-Safe DSL for MongoDBScala Days 2011 - Rogue: A Type-Safe DSL for MongoDB
Scala Days 2011 - Rogue: A Type-Safe DSL for MongoDB
 
Optimizing JavaScript and Dynamic Languages on the JVM
Optimizing JavaScript and Dynamic Languages on the JVMOptimizing JavaScript and Dynamic Languages on the JVM
Optimizing JavaScript and Dynamic Languages on the JVM
 

Similaire à Jax london 2011

OSGi and Java 9+ - BJ Hargrave (IBM)
OSGi and Java 9+ - BJ Hargrave (IBM)OSGi and Java 9+ - BJ Hargrave (IBM)
OSGi and Java 9+ - BJ Hargrave (IBM)mfrancis
 
OSGi and Java 9+
OSGi and Java 9+OSGi and Java 9+
OSGi and Java 9+bjhargrave
 
As7 jbug j_boss_modules_yang yong
As7 jbug j_boss_modules_yang yongAs7 jbug j_boss_modules_yang yong
As7 jbug j_boss_modules_yang yongjbossug
 
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)Martin Toshev
 
Preparing for java 9 modules upload
Preparing for java 9 modules uploadPreparing for java 9 modules upload
Preparing for java 9 modules uploadRyan Cuprak
 
OSGi made simple - Fuse Application Bundles
OSGi made simple - Fuse Application BundlesOSGi made simple - Fuse Application Bundles
OSGi made simple - Fuse Application BundlesRob Davies
 
Monoliths are so 2001 – What you need is Modularity
Monoliths are so 2001 – What you need is ModularityMonoliths are so 2001 – What you need is Modularity
Monoliths are so 2001 – What you need is ModularityGraham Charters
 
JAVA_Day1_BasicIntroduction.pptx
JAVA_Day1_BasicIntroduction.pptxJAVA_Day1_BasicIntroduction.pptx
JAVA_Day1_BasicIntroduction.pptxMurugesh33
 
JAVAPart1_BasicIntroduction.pptx
JAVAPart1_BasicIntroduction.pptxJAVAPart1_BasicIntroduction.pptx
JAVAPart1_BasicIntroduction.pptxMurugesh33
 
Java Platform Module System
Java Platform Module SystemJava Platform Module System
Java Platform Module SystemVignesh Ramesh
 
Framework Modularity Layer - Glyn Normington, IBM
Framework Modularity Layer - Glyn Normington, IBMFramework Modularity Layer - Glyn Normington, IBM
Framework Modularity Layer - Glyn Normington, IBMmfrancis
 
Java Modularity with OSGi
Java Modularity with OSGiJava Modularity with OSGi
Java Modularity with OSGiIlya Rybak
 
Calling All Modularity Solutions: A Comparative Study from eBay
Calling All Modularity Solutions: A Comparative Study from eBayCalling All Modularity Solutions: A Comparative Study from eBay
Calling All Modularity Solutions: A Comparative Study from eBayTony Ng
 
Calling all modularity solutions
Calling all modularity solutionsCalling all modularity solutions
Calling all modularity solutionsSangjin Lee
 
MWLUG - Universal Java
MWLUG  -  Universal JavaMWLUG  -  Universal Java
MWLUG - Universal JavaPhilippe Riand
 

Similaire à Jax london 2011 (20)

OSGi and Java 9+ - BJ Hargrave (IBM)
OSGi and Java 9+ - BJ Hargrave (IBM)OSGi and Java 9+ - BJ Hargrave (IBM)
OSGi and Java 9+ - BJ Hargrave (IBM)
 
OSGi and Java 9+
OSGi and Java 9+OSGi and Java 9+
OSGi and Java 9+
 
As7 jbug j_boss_modules_yang yong
As7 jbug j_boss_modules_yang yongAs7 jbug j_boss_modules_yang yong
As7 jbug j_boss_modules_yang yong
 
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)
 
OSGi & Blueprint
OSGi & BlueprintOSGi & Blueprint
OSGi & Blueprint
 
Modular Java
Modular JavaModular Java
Modular Java
 
Preparing for java 9 modules upload
Preparing for java 9 modules uploadPreparing for java 9 modules upload
Preparing for java 9 modules upload
 
OSGi made simple - Fuse Application Bundles
OSGi made simple - Fuse Application BundlesOSGi made simple - Fuse Application Bundles
OSGi made simple - Fuse Application Bundles
 
Monoliths are so 2001 – What you need is Modularity
Monoliths are so 2001 – What you need is ModularityMonoliths are so 2001 – What you need is Modularity
Monoliths are so 2001 – What you need is Modularity
 
JAVA_Day1_BasicIntroduction.pptx
JAVA_Day1_BasicIntroduction.pptxJAVA_Day1_BasicIntroduction.pptx
JAVA_Day1_BasicIntroduction.pptx
 
JAVAPart1_BasicIntroduction.pptx
JAVAPart1_BasicIntroduction.pptxJAVAPart1_BasicIntroduction.pptx
JAVAPart1_BasicIntroduction.pptx
 
Java Platform Module System
Java Platform Module SystemJava Platform Module System
Java Platform Module System
 
Framework Modularity Layer - Glyn Normington, IBM
Framework Modularity Layer - Glyn Normington, IBMFramework Modularity Layer - Glyn Normington, IBM
Framework Modularity Layer - Glyn Normington, IBM
 
Java Introduction
Java IntroductionJava Introduction
Java Introduction
 
Java Modularity with OSGi
Java Modularity with OSGiJava Modularity with OSGi
Java Modularity with OSGi
 
Calling All Modularity Solutions: A Comparative Study from eBay
Calling All Modularity Solutions: A Comparative Study from eBayCalling All Modularity Solutions: A Comparative Study from eBay
Calling All Modularity Solutions: A Comparative Study from eBay
 
Calling all modularity solutions
Calling all modularity solutionsCalling all modularity solutions
Calling all modularity solutions
 
OSGi introduction
OSGi introductionOSGi introduction
OSGi introduction
 
MWLUG - Universal Java
MWLUG  -  Universal JavaMWLUG  -  Universal Java
MWLUG - Universal Java
 
Java 9, JShell, and Modularity
Java 9, JShell, and ModularityJava 9, JShell, and Modularity
Java 9, JShell, and Modularity
 

Dernier

Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 

Dernier (20)

Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 

Jax london 2011

  • 1. Java 8 and OSGi modularization Tim Ellison, IBM UK Labs Neil Bartlett, Paremus Ltd
  • 2. What is a module? Why do we need a module system? • Modules facilitate software engineering & enhanced runtime capabilities – Decomposition of complex systems – Software assemblies of pre-built modules – Provisioning / deployment, including module repositories – Versioning and configuration management • The module system is used to manage the modules, including installing, activating, resolving module requirements and conflicts. • Interacting with the module system provides a higher level abstraction than the language provides directly. 2
  • 3. Modules in Java • The module as a unit of encapsulation... • The Java language already has two kinds of module: classes and packages. – classes encapsulate fields and methods – packages encapsulate classes and resources • Problem: neither of these is a deployable unit (too granular, too tightly coupled). • Java's unit of deployment is the JAR file. – No encapsulation, therefore not a module! • Problem: need an entity that is a deployable unit of encapsulation. 3
  • 4. Desirable characteristics of a module • A module should be highly coherent. • A module should be loosely coupled to other modules. • A module should be explicit about what it provides to other modules. • A module should be explicit about what it depends on from other modules. 4
  • 5. Why modules for the Java runtime (JRE)? • Presently the JRE is a monolithic entity – in general the runtime must assume your application will use anything and everything – class loaders provide runtime type definition and isolation – download time and start-up time are directly impacted by the number of types available in the runtime • Application start-up time includes a linear search through the class path to find system and application code – e.g. Oracle 1.7 Windows bootclass path contains nearly 20k classes – resources.jar rt.jar jsse.jar jce.jar charsets.jar – rt.jar index alone is ~1Mb • To the JRE, your application's jars’ indexes are disjoint & unsorted – there are JRE implementation 'tricks' like look aside tables and shared classes that can help – class loading is a BIG time hog to amortize over the length of the run 5
  • 6. Why modules for the Java runtime (JRE)? - cont. • Dependency management – avoid “JAR hell” → trying satisfy competing requirements by simple path ordering – type name space comprising (unversioned) package name is often insufficient – e.g. my app depends upon foo-v2.jar and bar-v2.jar but foo-v2.jar depends upon bar-v1.jar -classpath foo-v2.jar; bar-v2.jar; bar-v1.jar –> my app “wins” -classpath foo-v2.jar; bar-v1.jar; bar-v2.jar –> foo “wins” • Module level visibility – public, protected, private and package-private level visibility means some implementation types (com.sun.) need to be marked public to be called by java. APIs. – convention asks people not to depend upon them... – • Version control – ability to define the compatibility of a module based on numbering scheme – different module versions for different target devices / resource goals 6
  • 7. Introducing Project Jigsaw • Project Jigsaw is an effort at OpenJDK – defining a simple module system for Java – modularizing the JRE itself – originally intended as an implementation detail for the JRE / applications, but being adopted as a Java standard (JSR) • Working within constraints of backwards compatibility – existing Java APIs “cannot” be changed – Some packages contain wildly different functionality e.g. java.util contains collection hierarchy and Locale infrastructure • Introduces language changes to define modules src/com/example/myclass.java src/com/example/myclassimpl.java src/module-info.java module com.example @ 1.0 { requires jdk.base; requires foo @ 2.0; requires bar @ 2.0; } 7
  • 8. What about OSGi? • Existing, mature, de facto modularity solution for Java applications. • Rich modularity model based on code-level (package) dependencies, module-level dependencies, and services. • First practical solution for effective component reuse – well supported by multiple implementations, tooling, etc. • Millions use applications built with OSGi – most application servers are based on OSGi Bundle-ManifestVersion: 2 • No language changes. Bundle-SymbolicName: com.ex.mybundle Bundle-Version: 1.0.0 – defines info in META-INF/MANIFEST.MF Import-Package: com.example.bar Export-Package: com.example.foo 8
  • 9. Module dependency resolution • The module system must resolve bundle dependencies, possibly in the face of multiple valid alternatives – e.g. my app depends upon (foo-v2.jar and (bar-v1.jar or bar-v2.jar)) and foo-v2.jar depends upon bar-v1.jar – if my app touches bar first, the module system may chose bar-v2.jar – if my app touches foo first, the module system will chose bar-v1.jar • OSGi's dynamic dependency resolution always finds the best fit for currently invoked bundles at runtime – Modules are apparent at runtime – Runtime activation lifecycle: installed, resolved, starting, active, stopping, uninstalled • Jigsaw resolves module dependencies during build, installation, or runtime – Gives opportunity for load time optimizations such as pre-verify, indexing, etc. 9
  • 10. OSGi Dependency Model • OSGi best practice is to depend on APIs. • APIs are defined in terms of packages. • Read almost any JSR. It defines the package(s) that the JSR specifies, e.g.: – JSR 112 → javax.resource.spi, cci – JSR 173 → javax.xml.stream – JSR 315 → javax.servlet (3.0) 10
  • 11. OSGi: As Simple As Possible... • The primary unit of sharing is the package. • Bundle A exports a package – Export-Package: api • Bundle B imports a package – Import-Package: api 11
  • 12. But No Simpler! • Module-to-module dependencies also supported – Require-Bundle: A • Most OSGi devs consider Require-Bundle to be deprecated. 12
  • 15. Import-Package vs Require-Bundle • Import-Package directly reflects reality • Can be derived straight from the code! • Require-Bundle is a parallel dependency system => manually maintained, hard to statically verify. 15
  • 16. Don't Split the Packages! • In OSGi, the package is king. • Import-Package will resolve to exactly one export of that package, and this is a good thing!! • Require-Bundle can be used when packages are split for legacy/stupid reasons. 16
  • 17. More On Split Packages • Java packages were never meant to be split across deployment units. • Even plain Java provides a way to enforce this: Sealed Packages. • You wouldn't split a method across classes... or a class across packages... 17
  • 18. Handling platform-specific code • The JRE contains many classes and native code that are specific to an OS / CPU architecture • “Universal modules” – Contain code for all platforms – Requires download of unused code, and new revisions that are not relevant • “Platform-specific sub-modules” – Put platfom-specific code in a separate module – Many of the differences are in the native code only, so requires a native module • “Native package” – Hooks into the OS packaging system, so that dependencies can be handled by the OS (e.g. .deb file) 18
  • 19. Handling platform-specific code – OSGi style • OSGi allows you to deliver platform-specific native code in a bundle JAR file. Bundle-NativeCode: libfoo.so; osname=Linux; processor=x86, foo.dll; osname=Windows7; processor=x86 • The OSGi implementation of ClassLoader#findLibrary(“foo”) returns the path to the correct version. • Flexibility to structure as a universal module, or sub-module. http://www.osgi.org/Specifications/Reference 19
  • 20. Modularising the JRE • JRE libraries evolved organically (haphazardly!) over 12+ years. • Many cyclic dependencies • Many weird/unexpected dependencies • In particular java.util is an incoherent mess (this always happens to general util packages!) • => Split packages are unavoidable 20
  • 21. Can We Use OSGi? • OSGi does support split packages, through Require-Bundle • Works, though considered deprecated. • But that's not the whole story. 21
  • 22. Single Boot Classloader Assumption • Many parts of the JRE assume a single boot classloader. • Private package (aka “default”) access assumes whole packages are in single classloader. • Therefore need to split some packages across modules but not across classloaders. => Need to break 1-to-1 module/classloader mapping. 22
  • 23. But OSGi Supports Classloader Sharing! • True, through “fragments”. • Fragments share the CL of their “host”. • Dependency is in the “wrong” direction, i.e. fragment depends on host. • Can OSGi be modified to support host-to- fragment dependencies? • Almost certainly! 23
  • 24. Refactoring Verboten • Normal and best solution: move classes to the correct, i.e. most logical package. • In the JRE is this impossible! • 9 million developers (Sun estimate, 2009) and billions of apps depend on this library. 24
  • 25. Irrelevant Stuff • Let's not worry about: – Format of metadata – Location of metadata – Format of deployable modules • Differences here are surmountable • E.g. OSGi already supports WAR file deployment. 25
  • 26. Less Important Stuff • Let's even not worry about versioning right now. • 3 numeric segments vs 20... • Qualifier ordering, snapshots... • Again, we can adapt. 26
  • 27. Jigsaw Dependency Model • Modules require other modules by name (and optionally, version) module B @ 1.0 { require A @ [2.0,3.0); } 27
  • 28. Jigsaw Dependency Model • Requirements can be “local”. • Target module is loaded in same classloader as present module. module B @ 1.0 { require local A @ [2.0,3.0); } 28
  • 29. Jigsaw Dependency Model • Modules list their exports: at package and type level. • May include re-exported contents of required modules module B @ 1.0 { require A @ [2.0,3.0); export org.foo.ClassFoo; export org.bar.* } 29
  • 30. Jigsaw Dependency Model • Modules can restrict which other modules are allowed to require them. • Compare: “friend classes” in C++. • Note that the permit clause is un-versioned. module A @ 2.0 { permit B; } 30
  • 31. Jigsaw Dependency Model • Modules can logically “provide” other module names. • Compare: “virtual packages” in Debian. • Supports substitution, but unclear how it will support refactoring (splitting/aggregating). module com.ibm.stax @ 1.0 { provide jdk.stax @ 2.0; } 31
  • 32. Jigsaw Versions • Jigsaw modules will be versioned • Module requirements use exact version or a range • Versions have no semantics besides ordering 32
  • 33. Comparison • Whole-module dependencies are the biggest difference. • Jigsaw will suffer all the same problems seen in OSGi with Require-Bundle. • E.g. Eclipse Core Runtime refactoring hell. • While Jigsaw will achieve JDK modularity it will increase developer maintenance burden. 33
  • 34. Both Are Here to Stay! • Try to get the best of both worlds! • OSGi is established and will continue to be used by millions • Jigsaw is underway and a key component in Java 8 plans (Summer 2013) • It need not be a zero-sum game 34
  • 35. Project Penrose: Jigsaw / OSGi interop (proposed) • Level 0 : toleration – ensure that OSGi frameworks continue to run unmodified on a Jigsaw enabled runtime – creating modules / bundles that have both Jigsaw & OSGi metadata on the same JAR • Level 1 : interop of module info metadata – teach OSGi to read Jigsaw module info • mapping Jigsaw metadata into OSGi format for the framework to understand, e.g. requires ⇒ Require-Bundle: – resolve Jigsaw modules using the OSGi resolver 35
  • 36. Project Penrose: Jigsaw / OSGi interop (proposed) • Level 2 : OSGi implementation exploit of Jigsaw modularity – Enhance OSGi to use Jigsaw publication repositories etc. • Level 3+ : Full interop – A blend of OSGi and Jigsaw cross delegation on module phases OSGi support It must be demonstrated by prototype to be feasible to modify an OSGi micro- kernel such that OSGi bundles running in that kernel can depend upon Java modules. The kernel must be able to load Java modules directly and resolve them using its own resolver, except for core system modules. Core system modules can only be loaded using the module system’s reification API. http://openjdk.java.net/projects/jigsaw/doc/draft-java-module-system-requirements-12 36
  • 37. Project Penrose: results to date • Level 0 : toleration – ensure that OSGi frameworks continue to run unmodified on a Jigsaw enabled runtime – creating modules / bundles that have both Jigsaw & OSGi metadata on the same JAR • Achievement #1: pass the OSGi tests on a Jigsaw enabled runtime – Equinox 3.7 – the OSGi reference implementation – OSGi 4.3 Compliance Tests – with minor patch for test case error – Windows XP sp3, junit-3.8.2, java6u26, java7-ea-b145 • Achievement #2: run a Java application as either OSGi or Jigsaw modules – Took Java 2D demo – Broke it into multiple functional units, and run the demo as OSGi bundles OR Jigsaw modules 37
  • 38. Project Penrose: next steps • Level 1 : interop of module info metadata – teach OSGi to read Jigsaw module info • mapping Jigsaw metadata into OSGi format for the framework to understand, e.g. requires ⇒ Require-Bundle: – resolve Jigsaw modules using the OSGi resolver • Goal #0: move the work into a new OpenJDK project • Goal #1: map Jigsaw module metadata to OSGi equivalents – discussions of how OSGi shall interpret Jigsaw directives • Goal #2: modify OSGi to use Jigsaw reification APIs – load a third-party module from the Jigsaw repository – resolve it using the OSGi resolver 38
  • 39. Advice • Stop using internal APIs and implementation classes – You will be broken come Java 8 • If you need a modularity story that works before summer 2013 then the answer is OSGi – OSGi will continue to work beyond Java 7 too so it is the safest option • OSGi has greater expressiveness – While you may not need it now, do you want to change system when you do need it? • Think about how to interoperate with Jigsaw – Be modest in your API usage and we can likely help with a tailored JRE 39
  • 40. Questions • Tim Ellison – t.p.ellison@gmail.com • Neil Bartlett – njbartlett@gmail.com 40