SlideShare a Scribd company logo
Java 9 Modules.
The Duke Yet Lives That OSGi Shall Depose
Nikita Lipsky
Excelsior LLC
1
2
Modules in IDE
3
Modules in Maven
com.foo
app
1.0
com.foo
parse-api
2.0
com.foo
persist-api
3.0
org.apache
commons
2.1
org.apache
commons-io
3.1
4
Modules in Maven
com.foo
app
1.0
com.foo
parse-api
2.0
com.foo
persist-api
3.0
org.apache
commons
2.1
org.apache
commons
3.1
5
OSGi
6
Why Jigsaw is not OSGi?
Mark Reinhold (the Chief Architect of the Java Platform Group):
β€œβ€¦As it (OSGi) stands, moreover, it’s useful for
library and application modules but, since it’s
built strictly on top of the Java SE Platform, it
can’t be used to modularize the Platform itself”
7
Why Jigsaw is not OSGi?
Question: why the presence of j.l.Object in Java
Language Specification, implemented in Java in
turn, does not lead to a bootstrap problem?
Π€Π°ΠΊΡ‚: БущСствуСт рСализация Java SE, Π³Π΄Π΅
OSGi поддСрТиваСтся Π½Π° ΡƒΡ€ΠΎΠ²Π½Π΅ JVM (Π½Π°
ΡƒΡ€ΠΎΠ²Π½Π΅ ΠΏΠ»Π°Ρ‚Ρ„ΠΎΡ€ΠΌΡ‹).
8
Why Jigsaw is not OSGi?
Question: why the presence of j.l.Object in Java
Language Specification, implemented in Java in
turn, does not lead to a bootstrap problem?
Fact: There is a Java SE implementation that
supports OSGi at the JVM level (at the platform
level).
9
Nikita Lipsky
β€’ 20+ years in software development
β€’ Excelsior JET project initiator
– 16+ years of contributions
– compiler engineer
– team lead
– product lead
– etc.
β€’ Twitter: @pjBooms
10
Excelsior JET?
β€’ AOT-centric Java SE implementation
– certified as Java Compatible since 2005
β€’ AOT compiler + Java Runtime
– mixed compilation: AOT + JIT
– AOT support for custom classloaders (Eclipse RCP, Tomcat)
β€’ Toolkit
– Startup Optimizer
– Deployment
11
Agenda
β€’ Why OSGi
β€’ How OSGi does it
β€’ Why NOT OSGi
β€’ Why Jigsaw is not OSGi
β€’ Jigsaw mantra
β€’ Jigsaw problems
12
Where OSGi?
Standardized by OSGi Alliance (IBM, Adobe, Bosch,
Huawei, NTT, Oraсle)
Implementations:
β€’ Equinox
– Eclipse IDE, Eclipse RCP, IBM Websphere
β€’ Apache Felix
– Oracle WebLogic, Glassfish, Netbeans
13
Why OSGi?
14
Why OSGi?
β€’ Modularity
– Reduced complexity
– Hide internals (encapsulation)
– Dependency management and easy deployment
β€’ Dynamic updates
β€’ Versioning
β€’ Lazy
β€’ Simple, fast, small, secure, etc.
https://www.osgi.org/developer/benefits-of-using-osgi/
15
ΠœΠΎΠ΄ΡƒΠ»ΡŒΠ½Π°Ρ систСма OSGi
16
OSGi Module System
OSGi module – Bundle:
β€’ Jar or directory
β€’ Import/export is defined in META-INF/MANIFEST.MF:
Manifest-Version: 1.0 Bundle-ManifestVersion: 2
Bundle-SymbolicName: B
Bundle-Version: 1
Bundle-Name: B Bundle
Export-Package: org.bar
Import-Package: org.foo;version=β€œ[1,2)”
17
OSGi Module System
β€’ OSGi bundle imports/exports
– packages (Import-Package/Export-Package)
– services (Import-Service/Export-Service).
β€’ May import other bundles directly
– Require-Bundle directive
– However it is not the best practice (less flexible)
18
OSGi Module System
19
Bundle A
Class A
Bundle B
Class B
Bundle C
Class C
Export-Package: packageC
Import-Package: packageA
Export-Package: packageA
I
Import-Package: packageA,
packageC
OSGi Runtime
β€’ Resolves Import/Export of OSGi bundles
(wiring)
β€’ Defines bundle life cycle
– May start (activate) bundles lazily
– Enables on-the-fly bundle updates without system
restart (aka hot redeploy).
20
Jar/Classpath Hell
App
1.0
Library
Foo
2.0
Library
Bar
3.0
Library
Baz
2.1
Library
Baz
3.1
21
Versioning in OSGi
β€’ OSGI resolves JAR hell:
– import/export is qualified by version
– If two bundles require a library bundle of two
different versions, both versions will be loaded
22
Why OSGi?
So, OSGi promises:
β€’ Modularity
– explicit dependencies
– encapsulation
β€’ JAR Hell problem resolution
– via versioning
β€’ Hot ReDeploy
– via ability to update a separate bundle dynamically
23
Why OSGi?
So, OSGi promises:
β€’ Modularity
– explicit dependencies
– encapsulation
β€’ JAR Hell problem resolution
– via versioning
β€’ Hot ReDeploy
– via ability to update a separate bundle dynamically
24
Why OSGi?
So, OSGi promises:
β€’ Modularity
– explicit dependencies
– encapsulation
β€’ JAR Hell problem resolution
– via versioning
β€’ Hot ReDeploy
– via ability to update a separate bundle dynamically
25
Why OSGi?
So, OSGi promises:
β€’ Modularity
– explicit dependencies
– encapsulation
β€’ JAR Hell problem resolution
– via versioning
β€’ Hot ReDeploy
– via ability to update a separate bundle dynamically
26
27
How OSGi?
28
Versioning in OSGi
Question: How to implement versioning?
Task: For given A module importing Lib (v1)
library, and B module importing Lib (v2), it is
required that both versions of Lib working
without conflicts.
Solution: load the versions of the library by
different classloaders.
29
Versioning in OSGi
Question: How to implement versioning?
Task: For a given module A importing library Lib
(v1), and module B importing Lib (v2), it is
required that both versions of Lib work without
conflicts.
Solution: load the versions of the library by
different classloaders.
30
Versioning in OSGi
Question: How to implement versioning?
Task: For a given module A importing library Lib
(v1), and module B importing Lib (v2), it is
required that both versions of Lib work without
conflicts.
Solution: load versions of the library by different
classloaders.
31
Versioning in OSGi
Thus each OSGi bundle is loaded by its own
classloader:
β€’ Subtype of java.lang.ClassLoader
β€’ Unique class namespace
β€’ No conflicts with classes of other bundles
32
Versioning in OSGi
33
com.foo
App
1.0
com.foo
parse-api
2.0
com.foo
persist-api
3.0
org.apache
commons
2.1
org.apache
commons
3.1
CL
CL
CL
CL
CL
Different versions of apache
commons may simultaneously
present in the JVM
Each bundle has
its own classloader
Encapsulation in OSGi
34
Encapsulation in OSGi
src/com/foo/exported/A.java:
package com.foo.exported;
import com.foo.internal.B;
public class A {
B useB;
}
src/com/foo/internal/B.java:
package com.foo.internal;
public class B {
}
How to make the class B inaccessible from outside?
35
Encapsulation in OSGi
Question: how to make an internal class of a
module declared public inaccessible outside?
36
Encapsulation in OSGi
Question: how to make an internal class of a
module declared public inaccessible outside?
Answer: classloaders (!) may hide internal
classes.
37
Dynamic Updates
Task: update one (!) changed bundle in a
running program without stopping it
38
Dynamic Updates
Task: update one (!) changed bundle in a
running program without stopping it
Solution: CLASSLOADERS!
(unload old bundle, load new bundle by a new
classloader)
39
Bundle life cycle
40
Lazy start
Start of bundles in OSGi is implemented via the
bundle activators feature:
β€’ Each bundle may have an activator
– Bundle-Activator manifest directive
– Implementation of an interface with methods
start(), stop()
– Static class initializer analogue for bundles
41
Lazy start
Start of bundles in OSGi is implemented via the
bundle activators feature:
public interface BundleActivator {
void start(BundleContext context) throws Exception;
void stop(BundleContext context) throws Exception;
}
42
Lazy start
β€’ Bundle start can be defined by OSGi
configuration
β€’ Otherwise the bundle starts when it is
required by other started bundles
43
Lazy start
Task: start (load) bundles only when they
become needed for program execution
44
Lazy start
Solution: CLASSLOADERS (again!) in OSGi invoke
the start()method of the bundle activator
right before loading of the first class of a bundle
Since classloading in the JVM is lazy, bundle
activation becomes lazy AUTOMATICALLY
45
Lazy start
Solution: CLASSLOADERS (again!) in OSGi invoke
the start()method of the bundle activator
right before loading of the first class of a bundle
Since classloading in the JVM is lazy, bundle
activation becomes lazy AUTOMATICALLY
46
Lazy start
Solution: CLASSLOADERS (again!) in OSGi invoke
the start()method of the bundle activator
right before loading of the first class of a bundle
Since classloading in the JVM is lazy, bundle
activation becomes lazy AUTOMATICALLY
47
How OSGi?
All solved in one fell swoop!
48
49
Why Not OSGi?
50
Modularity?
Bundle A
Bundle B
51
Modularity?
Bundle A
Bundle B Bundle C
52
Modularity?
Bundle A
Bundle B Bundle C
Bundle D
53
Modularity?
Bundle A
Bundle B Bundle C
Bundle D
54
Modularity?
Bundle A
Bundle B Bundle C
Bundle D
55
Modularity?
Bundle A
Bundle B Bundle C
Bundle D
56
Modularity?
OSGI allows cycles in
the dependency graph
Exercise: understand, why
that is bad
A
B C
D
57
On the fly updates?
58
On the fly updates?
Bundle ABundle B
59
On the fly updates?
Bundle ABundle B
Let’s update bundle B
60
On the fly updates?
Bundle ABundle B
61
On the fly updates?
Bundle A
Bundle B
62
On the fly updates?
Bundle A
NEW
Bundle B
63
On the fly updates?
Bundle ANEW
Bundle B
64
On the fly updates?
Bundle ABundle B
Does it work for bundle A?
65
On the fly updates?
Bundle B
Class B
Bundle A
Class А
66
On the fly updates?
Bundle B
Class B
Bundle A
Class А
If bundle B imports bundle А then there is a
class from B that references a class from A
67
Symbolic references resolution
B.java:
class B {
A useA;
int f1 = A.f;
int f2 = A.foo();
}
A.java:
class A {
static int f;
static int foo(){};
}
68
Symbolic references resolution
69
B.class
…
CONSTANT_Class: A
CONSTANT_FieldRef: A.f@int
CONSTANT_MethodRef: A.foo()I
…
A.class
…
Field: f@int
Method: foo()I
…
Symbolic references resolution
β€’ A class references other classes and their
fields/methods symbolically
70
Symbolic references resolution
β€’ A class references other classes and their
fields/methods symbolically
β€’ JVM resolves those symbolic references with
real values at runtime
71
Symbolic references resolution
β€’ A class references other classes and their
fields/methods symbolically
β€’ JVM resolves those symbolic references with
real values at runtime
β€’ Once a reference is resolved, the value of the
reference is never changed!
72
On the fly updates?
β€’ If a reference from a class B to a class A is
resolved then the class А cannot be unloaded
from the JVM without unloading the class B
73
On the fly updates?
β€’ If a reference from a class B to a class A is
resolved then the class А cannot be unloaded
from the JVM without unloading the class B
β€’ Hence if a bundle Π’ imports a bundle А then
the bundle А cannot be unloaded without
also unloading the bundle B
74
On the fly updates?
Bundle ABundle B
Let’s update bundle A
75
On the fly updates?
Bundle ABundle B
76
On the fly updates?
Bundle A
Bundle B
77
On the fly updates?
Π‘Π°Π½Π΄Π» ABundle B
78
On the fly updates?
Now let’s remember
cyclic dependencies
Exercise: try to update
SWT bundle in running Eclipse
A
B C
D
79
80
On the fly updates?
β€’ On the fly updates in OSGi work, more or less,
only for leaf bundles that are not imported by
other bundles – plugins
81
On the fly updates?
β€’ On the fly updates in OSGi work, more or less,
only for leaf bundles that are not imported by
other bundles – plugins
β€’ There are much simpler ways than OSGi to
implement plugins
82
On the fly updates?
Even leaf bundles are not so easy to unload from
the JVM:
β€’ The classes from leaf bundles can live in the
JVM after their unloading
– Known problem: Classloaders Memory Leak
83
One does not simply
unload a class from the JVM 84
Versioning?
85
Versioning?
App
1.0
Foo
2.0
Bar
3.0
Baz
2.1
Baz
3.1
86
Versioning?
App
1.0
Foo
2.0
Bar
3.0
Baz
2.1
Baz
3.1
87
Versioning?
App
1.0
Foo
2.0
Bar
3.0
Baz
2.1
Baz
3.1
A
88
Versioning?
App
1.0
Foo
2.0
Bar
3.0
Baz
2.1
Baz
3.1
A A
89
Versioning?
App
1.0
Foo
2.0
Bar
3.0
Baz
2.1
Baz
3.1
A
A
90
Versioning?
App
1.0
Foo
2.0
Bar
3.0
Baz
2.1
Baz
3.1
A A
91
Versioning?
App
1.0
Foo
2.0
Bar
3.0
Baz
2.1
Baz
3.1
A A
92
Versioning?
App
1.0
Foo
2.0
Bar
3.0
Baz
2.1
Baz
3.1
A A
I’m β€œA”!
93
Versioning?
App
1.0
Foo
2.0
Bar
3.0
Baz
2.1
Baz
3.1
A A
I’m β€œA”!
No, I’m
β€œA”!
94
Versioning?
App
1.0
Foo
2.0
Bar
3.0
Baz
2.1
Baz
3.1
AAAAA!AAAAA!
AA
95
96
Loading constraints
β€’ Loading constraints prohibit two classes with
the same fully qualified name to appear in the
namespace of another class
97
Loading constraints
B.java:
class B {
T1 f1 = A.f;
int f2 = A.m(t2);
}
A.java:
class A {
static T1 f;
static int m(T2 t)
If B is loaded by L1 classloader and A is loaded by L2 then the
JVM will check that (T1, L1) = (T1, L2) and (T2, L1) = (T2, L2)
==
98
Versioning?
β€’ JVM throws java.lang.LinkageError on loading
constraints violation
99
Versioning?
β€’ JVM throws java.lang.LinkageError on loading
constraints violation
β€’ OSGi DOES NOT help developers to avoid
loading constraints violation
– Just google for β€œOSGI” and β€œLinkageError” to
estimate the scale of the problem
100
Versioning?
There are bundles in the latest Eclipse versions
with potential loading constraints violations and
nobody cares!
101
Versioning?
Conclusion: OSGi does not solve JAR Hell but
raises it to a new, more sophisticated level.
102
Versioning?
Conclusion: Do not use two different versions of
the same library in one application!
103
Encapsulation?
Question: well, at least the encapsulation
problem is solved by OSGi, right?
104
Reflection – universal countermeasure
against encapsulation in Java
Encapsulation?
setAccessible(true)
105
Encapsulation?
Question: well, at least the encapsulation
problem is solved by OSGi, right?
Answer: OSGi does not protect from
unauthorized access via Reflection
106
Lazy start?
107
Lazy start?
108
Lazy start?
Bundle A
Bundle B Bundle C
Question: in what order the bundles will be activated?
109
Lazy start?
Bundle activation order in OSGi depends on
classloading order directly
– A bundle is started from loadClass() of the
bundle classloader
110
Lazy start?
Bundle activation order in OSGi depends on
classloading order directly
– A bundle is started from loadClass() of the
bundle classloader
However, class loading order is not defined by
the JVM specification!
111
Symbolic references resolution
A class may reference other classes and their
fields/methods symbolically. A JVM may resolve
references:
β€’ Lazily
– Each reference is resolved on first access
β€’ Eagerly
– All references are resolved at the time of class loading
112
Lazy start?
The classloading order depends on the class
reference resolution scheme in the given JVM
implementation: lazy, less lazy, eager.
113
Lazy start?
Bundle B activator:
class B implements BundleActivator {
public void start() {
assert A.f!= null;
}
Bundle A activator:
class A implements BundleActivator {
static T f;
public void start() {
f = new T();
}
Typical case: Π’ thinks that А is already activated, but in fact
А can be activated after B, so assertion fails
114
Lazy start?
β€’ Bundle activation scheme in OSGi is a time
bomb:
– If the JVM starts to resolve class references less
lazily, practically all OSGi applications will stop
working
115
Why NOT OSGi?
β€’ Modularity with cycles
β€’ Hot Redeploy works for leaf bundles only
β€’ No protection from loading constraints violation
β€’ No protection of implementation details from
reflective access
β€’ Bundle activation order depends substantially
on class reference resolution scheme
116
Jigsaw
117
Jigsaw
118
Jigsaw vs. OSGi
OSGi is dynamic essentially
– modules appear at run time only
119
Jigsaw vs. OSGi
Jigsaw was thought up as static from the beginning.
Practically all JDK tools know about modules:
– javac: respects modules visibility rules
– jdeps: analyses dependencies
– jar, jmod: pack modules
– jlink: prepares final image for deployment
– java: there are modules in runtime as well
120
Module example
// src/java.sql/module-info.java
module java.sql {
requires transitive java.logging;
requires transitive java.xml;
exports java.sql;
exports javax.sql;
exports javax.transaction.xa;
uses java.sql.Driver;
}
121
Jigsaw vs. OSGi
Jigsaw prohibits (explicit) cycles
in the dependency graph
Modules import modules
and not packages.
122
Versioning
There was versioning in the first drafts of Jigsaw
(similar to OSGi).
123
Versioning
There was versioning in the first drafts of Jigsaw
(similar to OSGi).
However versioning was removed later …
124
Versioning
There was versioning in the first drafts of Jigsaw
(similar to OSGi).
However versioning was removed later …
Why?
125
Versioning
Versioning immediately means:
1 module οƒŸοƒ  1 classloader
126
Versioning
Versioning immediately means:
1 module οƒŸοƒ  1 classloader
It was exactly so in the first Jigsaw drafts!
127
Jigsaw and classloaders
Jigsaw is not just modules, but also the Java SE
platform split into modules.
128
Jigsaw and classloaders
Backward compatibility problem:
According to the specification
getClassloader() == null
for core platform classes.Ρ‚ΠΎ ΠΏΡ€ΠΎΡ‚ΠΈΠ²ΠΎΡ€Π΅Ρ‡ΠΈΡ‚
That precludes splitting of the platform into
modules, with each module loaded by its loader
129
Jigsaw and classloaders
Backward compatibility problem:
According to the specification
getClassloader() == null
for core platform classes.Ρ‚ΠΎ ΠΏΡ€ΠΎΡ‚ΠΈΠ²ΠΎΡ€Π΅Ρ‡ΠΈΡ‚
That precludes splitting of the platform into
modules, with each module loaded by its loader
130
Jigsaw and classloaders
Problem 2: How to protect developers from
loading constraints violation?
131
Versioning
Another detail: import in early Jigsaw versions
(as in OSGi) was qualified by not a single version
but by Π° version range:
– A module may declare that it can work with a
dependency of β€œfrom” version to β€œto” version
132
Versioning
Problem 3: Resolving dependencies (wiring
modules) from version ranges is an NP-complete
problem!
– Reduced to 3-SAT
133
Versioning
… after that versioning in JPMS breathed its last.
134
Versioning
… after that versioning in JPMS breathed its last.
No versioning – no classloaders for modules.
135
Jigsaw
β€’ No dynamic updates
β€’ No versioning
136
Jigsaw
β€’ No dynamic updates
β€’ No versioning
So what does it have?
137
Jigsaw Mantra
Reliable
Configuration
Strong
Encapsulation
138
Reliable Configuration
Вакая ситуация Π² Jigsaw просто Π·Π°ΠΏΡ€Π΅Ρ‰Π΅Π½Π°!
App
1.0
Foo
2.0
Bar
3.0
Baz
2.1
Baz
3.1
139
Reliable Configuration
Jigsaw simply prohibits this situation!
App
1.0
Foo
2.0
Bar
3.0
Baz
2.1
Baz
3.1
140
Reliable Configuration
Right (reliable) configuration:
App
1.0
Foo
2.5
Bar
3.0
Baz
3.1
141
Reliable Configuration
Reliable configuration:
β€’ All module dependencies are resolved
β€’ No cyclic dependencies
β€’ No modules containing the same packages
(split packages)
These properties are checked at startup (wiring)
142
Strong Encapsulation
setAccessible(true)
143
Strong Encapsulation
Java 9 modules are first class citizens
β€’ Define visibility access rules
– via declared export
β€’ There is no access to non-exported functionality
outside of the module even via reflection
– Even setAccessible(true) does not work
144
Strong Encapsulation
Java 9 modules are first class citizens
β€’ Define visibility access rules
– via declared export
β€’ There is no access to non-exported functionality
outside of the module even via reflection
– Even setAccessible(true) does not work
145
Strong Encapsulation
Java 9 modules are first class citizens
β€’ Define visibility access rules
– via declared export
β€’ There is no access to non-exported functionality
outside of the module even via reflection
– Even setAccessible(true) does not work
146
So Jigsaw does not have problems?
147
148
Reliable Configuration?
β€’ Reflective access was prohibited between
modules without explicit dependencies in
early Jigsaw drafts
β€’ However it had to be relaxed when
classloaders had gone from JPMS
– because Class.forName() has to work
backward compatible
149
Reliable Configuration?
β€’ Reflective access was prohibited between
modules without explicit dependencies in
early Jigsaw drafts
β€’ Had to be relaxed when classloaders had gone
from JPMS
– because Class.forName() had to remain
backward compatible
150
Reliable Configuration?
However if you may have reflective
dependencies that are not explicitly declared,
where is the guarantee that the resulting
configuration is reliable?
151
Reliable Configuration?
Split packages are prohibited, but what about
application containers (Tomcat, Java EE)?
152
Jigsaw Layers *
To solve the application containers problem
Layers feature was introduced in JPMS:
β€’ Local module system for each application in a
container
β€’ Two modules containing the same package
have to belong to different layers
153
Jigsaw Layers *
* The picture is from Alex Buckley’s presentation: Project Jigsaw Under the hood
154
Strong Encapsulation?
155
Strong Encapsulation?
The platform is split into modules:
β€’ Which means that private APIs become really
private
156
Strong Encapsulation?
The platform is split into modules:
β€’ Which means that private APIs become really
private
β€’ But what about
sun.misc.Unsafe ?
157
Strong Encapsulation?
Ok, Java community (temporarily)
defended sun.misc.Unsafe (in an
unequal fight)!
158
Strong Encapsulation?
But what about Dependency Injection?
159
Strong Encapsulation?
DI frameworks essentially depend on:
β€’ reflective access to the code in
which they inject dependencies
β€’ including non-exported code
160
Strong Encapsulation?
module my.module {
exports my.module.pack;
}
161
Strong Encapsulation?
module my.module {
exports my.module.pack;
exports my.module.internal.object.orgy;
}
162
Strong Encapsulation?
module my.moduleO{
exports my.module.pack;
}
163
Strong Encapsulation?
open module my.module {
exports my.module.pack;
}
164
Strong Encapsulation?
Open modules were introduced to solve the DI
frameworks problem:
β€’ An open module allows reflective access to its
non-exported functionality
165
Strong Encapsulation?
Open modules provide not-so-strong
encapsulation, but it is better than nothing.
166
Jigsaw
Well, but what benefits me in Jigsaw at last?
167
Jigsaw benefits
If all your dependencies are on the classpath now,
migrating to the modulepath would improve the
architecture of your application by eliminating:
β€’ cycles in the dependencies
β€’ split packages (jar hell)
β€’ unsound access into implementation details of
other modules
β€’ dependencies to JDK private API
168
Jigsaw benefits
If all your dependencies are on the classpath now,
migrating to the modulepath would improve the
architecture of your application by eliminating:
β€’ cycles in the dependency graph
β€’ split packages (jar hell)
β€’ unsound access into implementation details of
other modules
β€’ dependencies to JDK private API
169
Jigsaw benefits
If all your dependencies are on the classpath now,
migrating to the modulepath would improve the
architecture of your application by eliminating:
β€’ cycles in the dependency graph
β€’ split packages (jar hell)
β€’ unsound access into implementation details of
other modules
β€’ dependencies to JDK private API
170
Jigsaw benefits
If all your dependencies are on the classpath now,
migrating to the modulepath would improve the
architecture of your application by eliminating:
β€’ cycles in the dependency graph
β€’ split packages (jar hell)
β€’ unsound reliance upon implementation details of
other modules
β€’ dependencies to JDK private API
171
Jigsaw benefits
If all your dependencies are on the classpath now,
migrating to the modulepath would improve the
architecture of your application by eliminating:
β€’ cycles in the dependency graph
β€’ split packages (jar hell)
β€’ unsound reliance upon implementation details of
other modules
β€’ dependencies on JDK private APIs
172
Jigsaw benefits
Jigsaw introduces a migration path to the
modulepath:
β€’ Old classpath forms Unnamed ModulΠ΅
β€’ Jars from classpath may be temporally moved as
is to modulepath as Auto Modules
β€’ Module declaration can be added to auto
modules later
173
Jigsaw benefits
Jigsaw introduces a migration path to the
modulepath:
β€’ Old classpath forms Unnamed Module
β€’ Jars from classpath may be temporally moved as
is to modulepath as Auto Modules
β€’ Module declaration can be added to auto
modules later
174
Jigsaw benefits
Jigsaw introduces a migration path to the
modulepath:
β€’ Old classpath forms Unnamed ModulΠ΅
β€’ Jars from classpath may be temporarily moved
β€œas-is” to modulepath as Auto Modules
β€’ Module declaration can be added to auto
modules later
175
Jigsaw benefits
Jigsaw introduces a migration path to the
modulepath:
β€’ Old classpath forms Unnamed ModulΠ΅
β€’ Jars from classpath may be temporarily moved
β€œas-is” to modulepath as Auto Modules
β€’ Module declaration can be added to auto
modules later
176
Jigsaw benefits
Unfortunately, most Java developers won’t benefit
from JPMS immediately:
β€’ Java EE standards do not define how they will
interoperate with JPMS yet
β€’ Even servlet containers standard knows nothing
about modules so far
– Dependencies in war Ρ„Π°ΠΉΠ»Π°Ρ… are essentially old plain
classpath!
177
Jigsaw benefits
Unfortunately, most Java developers won’t benefit
from JPMS immediately:
β€’ Java EE standards do not define how they will
interoperate with JPMS yet
β€’ Even the servlet container standard knows
nothing about modules so far
– Dependencies in war files are old plain classpath in
fact!
178
The birth is inevitable!
179
Conclusion
β€’ OSGi is a nice attempt to give modules to Java
developers
– but OSGi has many problems unfortunately
– including fundamental
β€’ Jigsaw is a carefully designed system without
visible fundamental problems
– but with a system of checks and balances
– there are community acceptance problems
180
Q & A
Nikita Lipsky,
Excelsior
nlipsky@excelsior-usa.com
twitter: @pjBooms 181

More Related Content

PDF
JIT Versus AOT: Unity And Conflict of Dynamic and Static Compilers (JavaOne 2...
Nikita Lipsky
Β 
PPTX
Ahead-Of-Time Compilation of Java Applications
Nikita Lipsky
Β 
PDF
Java SE 9 modules (JPMS) - an introduction
Stephen Colebourne
Β 
PDF
Java 9 preview
Ivan Krylov
Β 
PDF
Create *real* modular Java applications - a brief introduction -
Jeffrey Groneberg
Β 
PPSX
Introduction to Java
Hitesh-Java
Β 
PPTX
Java byte code & virtual machine
Laxman Puri
Β 
PPTX
Java introduction
The icfai university jaipur
Β 
JIT Versus AOT: Unity And Conflict of Dynamic and Static Compilers (JavaOne 2...
Nikita Lipsky
Β 
Ahead-Of-Time Compilation of Java Applications
Nikita Lipsky
Β 
Java SE 9 modules (JPMS) - an introduction
Stephen Colebourne
Β 
Java 9 preview
Ivan Krylov
Β 
Create *real* modular Java applications - a brief introduction -
Jeffrey Groneberg
Β 
Introduction to Java
Hitesh-Java
Β 
Java byte code & virtual machine
Laxman Puri
Β 
Java introduction
The icfai university jaipur
Β 

What's hot (20)

PPTX
Bytecode manipulation with Javassist for fun and profit
JΓ©rΓ΄me Kehrli
Β 
PDF
History of java
Mani Sarkar
Β 
PPTX
How to implement a simple dalvik virtual machine
Chun-Yu Wang
Β 
PPTX
JAVA BYTE CODE
Javed Ahmed Samo
Β 
PDF
Flavors of Concurrency in Java
JavaDayUA
Β 
PDF
Preparing your code for Java 9
Deepu Xavier
Β 
PPTX
Java Presentation
Amr Salah
Β 
PPTX
What's new in Java 11
Michel Schudel
Β 
PPTX
Intro to OSGi
Tricode (part of Dept)
Β 
PDF
Intro To OSGi
Stephan Janssen
Β 
PPTX
Escaping The Jar hell with Jigsaw Layers
Nikita Lipsky
Β 
PPT
What is Java Technology (An introduction with comparision of .net coding)
Shaharyar khan
Β 
PDF
Understanding Java Dynamic Proxies
Rafael Luque Leiva
Β 
PDF
History of Java 2/2
Eberhard Wolff
Β 
PDF
Java Course 6: Introduction to Agile
Anton Keks
Β 
PPTX
JRuby in Java Projects
jazzman1980
Β 
PDF
Lec 3 01_aug13
Palak Sanghani
Β 
PDF
Using Java from Ruby with JRuby IRB
Hiro Asari
Β 
DOCX
Java Tutorial to Learn Java Programming
business Corporate
Β 
Bytecode manipulation with Javassist for fun and profit
JΓ©rΓ΄me Kehrli
Β 
History of java
Mani Sarkar
Β 
How to implement a simple dalvik virtual machine
Chun-Yu Wang
Β 
JAVA BYTE CODE
Javed Ahmed Samo
Β 
Flavors of Concurrency in Java
JavaDayUA
Β 
Preparing your code for Java 9
Deepu Xavier
Β 
Java Presentation
Amr Salah
Β 
What's new in Java 11
Michel Schudel
Β 
Intro to OSGi
Tricode (part of Dept)
Β 
Intro To OSGi
Stephan Janssen
Β 
Escaping The Jar hell with Jigsaw Layers
Nikita Lipsky
Β 
What is Java Technology (An introduction with comparision of .net coding)
Shaharyar khan
Β 
Understanding Java Dynamic Proxies
Rafael Luque Leiva
Β 
History of Java 2/2
Eberhard Wolff
Β 
Java Course 6: Introduction to Agile
Anton Keks
Β 
JRuby in Java Projects
jazzman1980
Β 
Lec 3 01_aug13
Palak Sanghani
Β 
Using Java from Ruby with JRuby IRB
Hiro Asari
Β 
Java Tutorial to Learn Java Programming
business Corporate
Β 
Ad

Viewers also liked (11)

PDF
Working With Concurrency In Java 8
Heartin Jacob
Β 
PDF
Java9 Beyond Modularity - Java 9 mΓ‘s allΓ‘ de la modularidad
David GΓ³mez GarcΓ­a
Β 
PDF
Java 8 Stream API. A different way to process collections.
David GΓ³mez GarcΓ­a
Β 
PDF
Lambda Expressions in Java
Erhan Bagdemir
Β 
PDF
Java 9, JShell, and Modularity
Mohammad Hossein Rimaz
Β 
PPTX
Lambda Expressions in Java 8
icarter09
Β 
PPT
Java 8 Streams
Manvendra Singh
Β 
PDF
Java 8 Lambda Expressions & Streams
NewCircle Training
Β 
PDF
Parallel streams in java 8
David GΓ³mez GarcΓ­a
Β 
PPTX
The do's and don'ts with java 9 (Devoxx 2017)
Robert Scholte
Β 
PDF
Real World Java 9
Trisha Gee
Β 
Working With Concurrency In Java 8
Heartin Jacob
Β 
Java9 Beyond Modularity - Java 9 mΓ‘s allΓ‘ de la modularidad
David GΓ³mez GarcΓ­a
Β 
Java 8 Stream API. A different way to process collections.
David GΓ³mez GarcΓ­a
Β 
Lambda Expressions in Java
Erhan Bagdemir
Β 
Java 9, JShell, and Modularity
Mohammad Hossein Rimaz
Β 
Lambda Expressions in Java 8
icarter09
Β 
Java 8 Streams
Manvendra Singh
Β 
Java 8 Lambda Expressions & Streams
NewCircle Training
Β 
Parallel streams in java 8
David GΓ³mez GarcΓ­a
Β 
The do's and don'ts with java 9 (Devoxx 2017)
Robert Scholte
Β 
Real World Java 9
Trisha Gee
Β 
Ad

Similar to Java 9 Modules: The Duke Yet Lives That OSGi Shall Depose (20)

PPTX
Introduction to OSGi - Part-1
kshanth2101
Β 
PDF
Java Core | Java 8 and OSGi Modularisation | Tim Ellison & Neil Bartlett
JAX London
Β 
PDF
Jax london 2011
njbartlett
Β 
PDF
Open Services Gateway Initiative (OSGI)
Peter R. Egli
Β 
PDF
OSGI Modularity
Pubudu Lasal Dissanayake
Β 
PDF
Osgi Sun 20080820
Eduardo Pelegri-Llopart
Β 
PPTX
Introduction to OSGi
pradeepfn
Β 
PDF
OSGi introduction
Dario Bonino
Β 
KEY
Introduction to EclipseRT (JAX 2010)
Chris Aniszczyk
Β 
PPT
OSGi & Blueprint
Kara Satish Kumar
Β 
PDF
OSGi bootcamp - part 1
Jan Willem Janssen
Β 
PPTX
OSGi
Zeeshan Bilal
Β 
PPTX
OSGi Training for Carbon Developers
Aruna Karunarathna
Β 
PDF
Tuscany : Applying OSGi After The Fact
Luciano Resende
Β 
PDF
OSGi overview
Alex Proca
Β 
PDF
OSGi user forum dc metro v1
pjhInovex
Β 
PDF
OSGi User Forum US DC Metro
pjhInovex
Β 
PDF
OpenJDK Penrose Presentation (JavaOne 2012)
David Bosschaert
Β 
PPT
Managing Change
Mirko Jahn
Β 
KEY
First Touch with OSGi
Owen Ou
Β 
Introduction to OSGi - Part-1
kshanth2101
Β 
Java Core | Java 8 and OSGi Modularisation | Tim Ellison & Neil Bartlett
JAX London
Β 
Jax london 2011
njbartlett
Β 
Open Services Gateway Initiative (OSGI)
Peter R. Egli
Β 
OSGI Modularity
Pubudu Lasal Dissanayake
Β 
Osgi Sun 20080820
Eduardo Pelegri-Llopart
Β 
Introduction to OSGi
pradeepfn
Β 
OSGi introduction
Dario Bonino
Β 
Introduction to EclipseRT (JAX 2010)
Chris Aniszczyk
Β 
OSGi & Blueprint
Kara Satish Kumar
Β 
OSGi bootcamp - part 1
Jan Willem Janssen
Β 
OSGi Training for Carbon Developers
Aruna Karunarathna
Β 
Tuscany : Applying OSGi After The Fact
Luciano Resende
Β 
OSGi overview
Alex Proca
Β 
OSGi user forum dc metro v1
pjhInovex
Β 
OSGi User Forum US DC Metro
pjhInovex
Β 
OpenJDK Penrose Presentation (JavaOne 2012)
David Bosschaert
Β 
Managing Change
Mirko Jahn
Β 
First Touch with OSGi
Owen Ou
Β 

More from Nikita Lipsky (19)

PPTX
Java 9 ΠœΠΎΠ΄ΡƒΠ»ΠΈ. ΠŸΠΎΡ‡Π΅ΠΌΡƒ Π½Π΅ OSGi?
Nikita Lipsky
Β 
PDF
AOT для Java: ΠœΠΈΡ„Ρ‹ ΠΈ Challenges
Nikita Lipsky
Β 
PPTX
JIT vs. AOT: Unity And Conflict of Dynamic and Static Compilers
Nikita Lipsky
Β 
PPTX
ВСрификация Java Π±Π°ΠΉΡ‚ΠΊΠΎΠ΄Π°: ΠΊΠΎΠ³Π΄Π°, ΠΊΠ°ΠΊ, Π° ΠΌΠΎΠΆΠ΅Ρ‚ ΠΎΡ‚ΠΊΠ»ΡŽΡ‡ΠΈΡ‚ΡŒ?
Nikita Lipsky
Β 
PPTX
Java 8 Support at the JVM Level
Nikita Lipsky
Β 
PPTX
JVM: ΠΊΡ€Π°Ρ‚ΠΊΠΈΠΉ курс ΠΎΠ±Ρ‰Π΅ΠΉ Π°Π½Π°Ρ‚ΠΎΠΌΠΈΠΈ, JPoint 2016 Conference Edition
Nikita Lipsky
Β 
PPTX
ΠŸΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Java 8 Π² Excelsior JET
Nikita Lipsky
Β 
PPTX
JVM: ΠΊΡ€Π°Ρ‚ΠΊΠΈΠΉ курс ΠΎΠ±Ρ‰Π΅ΠΉ Π°Π½Π°Ρ‚ΠΎΠΌΠΈΠΈ
Nikita Lipsky
Β 
PPTX
ΠšΠ»ΠΈΠ΅Π½Ρ‚ΡΠΊΠ°Ρ Java Π²Π½Π΅ Π±Ρ€Π°ΡƒΠ·Π΅Ρ€Π°. Π”Π΅Π»Π°Π΅ΠΌ Π½Π°Ρ‚ΠΈΠ²Π½Ρ‹Π΅ ΠΊΠ»ΠΈΠ΅Π½Ρ‚Ρ‹ Π½Π° Java
Nikita Lipsky
Β 
PPTX
Delivering Native User Experience In Client Side Java Applications
Nikita Lipsky
Β 
PPTX
Java Restart with WebFX
Nikita Lipsky
Β 
PDF
Java Ρ…ΡƒΠ΄Π΅Π΅Ρ‚. Бпроси мСня ΠΊΠ°ΠΊ. УмСньшСниС Ρ€Π°Π·ΠΌΠ΅Ρ€Π° дистрибутива Java прилоТСния...
Nikita Lipsky
Β 
PPTX
Java Ahead-Of-Time compilation
Nikita Lipsky
Β 
PDF
Excelsior JET Π² дСйствии
Nikita Lipsky
Β 
PDF
Π’Π΅Π± 3.0. Π•ΡΡ‚ΡŒ Π»ΠΈ Π±ΡƒΠ΄ΡƒΡ‰Π΅Π΅ Ρƒ Java Π² RIA ΠΈ Mobile?
Nikita Lipsky
Β 
PDF
Π—Π°Π½ΠΈΠΌΠ°Ρ‚Π΅Π»ΡŒΠ½Ρ‹Π΅ истории ΠΈΠ· ΠΆΠΈΠ·Π½ΠΈ тСхничСской ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠΈ JVM
Nikita Lipsky
Β 
PPTX
НСумолимая Π±Π»ΠΈΠ·ΠΎΡΡ‚ΡŒ дСсктопа, Π²Π΅Π±Π° ΠΈ ΠΌΠΎΠ±Π°ΠΉΠ»Π°
Nikita Lipsky
Β 
PDF
Java Ρ…ΡƒΠ΄Π΅Π΅Ρ‚. Бпроси мСня ΠΊΠ°ΠΊ.
Nikita Lipsky
Β 
PPT
Π˜ΡΡ‚ΠΎΡ€ΠΈΡ ΠΎΠ΄Π½ΠΎΠΉ JVM Π² ΠΊΠ°Ρ€Ρ‚ΠΈΠ½ΠΊΠ°Ρ…
Nikita Lipsky
Β 
Java 9 ΠœΠΎΠ΄ΡƒΠ»ΠΈ. ΠŸΠΎΡ‡Π΅ΠΌΡƒ Π½Π΅ OSGi?
Nikita Lipsky
Β 
AOT для Java: ΠœΠΈΡ„Ρ‹ ΠΈ Challenges
Nikita Lipsky
Β 
JIT vs. AOT: Unity And Conflict of Dynamic and Static Compilers
Nikita Lipsky
Β 
ВСрификация Java Π±Π°ΠΉΡ‚ΠΊΠΎΠ΄Π°: ΠΊΠΎΠ³Π΄Π°, ΠΊΠ°ΠΊ, Π° ΠΌΠΎΠΆΠ΅Ρ‚ ΠΎΡ‚ΠΊΠ»ΡŽΡ‡ΠΈΡ‚ΡŒ?
Nikita Lipsky
Β 
Java 8 Support at the JVM Level
Nikita Lipsky
Β 
JVM: ΠΊΡ€Π°Ρ‚ΠΊΠΈΠΉ курс ΠΎΠ±Ρ‰Π΅ΠΉ Π°Π½Π°Ρ‚ΠΎΠΌΠΈΠΈ, JPoint 2016 Conference Edition
Nikita Lipsky
Β 
ΠŸΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Java 8 Π² Excelsior JET
Nikita Lipsky
Β 
JVM: ΠΊΡ€Π°Ρ‚ΠΊΠΈΠΉ курс ΠΎΠ±Ρ‰Π΅ΠΉ Π°Π½Π°Ρ‚ΠΎΠΌΠΈΠΈ
Nikita Lipsky
Β 
ΠšΠ»ΠΈΠ΅Π½Ρ‚ΡΠΊΠ°Ρ Java Π²Π½Π΅ Π±Ρ€Π°ΡƒΠ·Π΅Ρ€Π°. Π”Π΅Π»Π°Π΅ΠΌ Π½Π°Ρ‚ΠΈΠ²Π½Ρ‹Π΅ ΠΊΠ»ΠΈΠ΅Π½Ρ‚Ρ‹ Π½Π° Java
Nikita Lipsky
Β 
Delivering Native User Experience In Client Side Java Applications
Nikita Lipsky
Β 
Java Restart with WebFX
Nikita Lipsky
Β 
Java Ρ…ΡƒΠ΄Π΅Π΅Ρ‚. Бпроси мСня ΠΊΠ°ΠΊ. УмСньшСниС Ρ€Π°Π·ΠΌΠ΅Ρ€Π° дистрибутива Java прилоТСния...
Nikita Lipsky
Β 
Java Ahead-Of-Time compilation
Nikita Lipsky
Β 
Excelsior JET Π² дСйствии
Nikita Lipsky
Β 
Π’Π΅Π± 3.0. Π•ΡΡ‚ΡŒ Π»ΠΈ Π±ΡƒΠ΄ΡƒΡ‰Π΅Π΅ Ρƒ Java Π² RIA ΠΈ Mobile?
Nikita Lipsky
Β 
Π—Π°Π½ΠΈΠΌΠ°Ρ‚Π΅Π»ΡŒΠ½Ρ‹Π΅ истории ΠΈΠ· ΠΆΠΈΠ·Π½ΠΈ тСхничСской ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠΈ JVM
Nikita Lipsky
Β 
НСумолимая Π±Π»ΠΈΠ·ΠΎΡΡ‚ΡŒ дСсктопа, Π²Π΅Π±Π° ΠΈ ΠΌΠΎΠ±Π°ΠΉΠ»Π°
Nikita Lipsky
Β 
Java Ρ…ΡƒΠ΄Π΅Π΅Ρ‚. Бпроси мСня ΠΊΠ°ΠΊ.
Nikita Lipsky
Β 
Π˜ΡΡ‚ΠΎΡ€ΠΈΡ ΠΎΠ΄Π½ΠΎΠΉ JVM Π² ΠΊΠ°Ρ€Ρ‚ΠΈΠ½ΠΊΠ°Ρ…
Nikita Lipsky
Β 

Recently uploaded (20)

PPTX
slidesgo-unlocking-the-code-the-dynamic-dance-of-variables-and-constants-2024...
kr2589474
Β 
PDF
Applitools Platform Pulse: What's New and What's Coming - July 2025
Applitools
Β 
PDF
ChatPharo: an Open Architecture for Understanding How to Talk Live to LLMs
ESUG
Β 
PDF
Enhancing Healthcare RPM Platforms with Contextual AI Integration
Cadabra Studio
Β 
PPTX
Web Testing.pptx528278vshbuqffqhhqiwnwuq
studylike474
Β 
PDF
On Software Engineers' Productivity - Beyond Misleading Metrics
RomΓ©n RodrΓ­guez-Gil
Β 
PDF
New Download MiniTool Partition Wizard Crack Latest Version 2025
imang66g
Β 
PDF
What to consider before purchasing Microsoft 365 Business Premium_PDF.pdf
Q-Advise
Β 
PDF
lesson-2-rules-of-netiquette.pdf.bshhsjdj
jasmenrojas249
Β 
PPTX
Visualising Data with Scatterplots in IBM SPSS Statistics.pptx
Version 1 Analytics
Β 
PPTX
Maximizing Revenue with Marketo Measure: A Deep Dive into Multi-Touch Attribu...
bbedford2
Β 
PDF
Immersive experiences: what Pharo users do!
ESUG
Β 
PPT
Activate_Methodology_Summary presentatio
annapureddyn
Β 
PDF
Generating Union types w/ Static Analysis
K. Matthew Dupree
Β 
PPTX
The-Dawn-of-AI-Reshaping-Our-World.pptxx
parthbhanushali307
Β 
PDF
MiniTool Power Data Recovery Crack New Pre Activated Version Latest 2025
imang66g
Β 
PDF
Key Features to Look for in Arizona App Development Services
Net-Craft.com
Β 
PDF
advancepresentationskillshdhdhhdhdhdhhfhf
jasmenrojas249
Β 
PDF
WatchTraderHub - Watch Dealer software with inventory management and multi-ch...
WatchDealer Pavel
Β 
PPTX
Presentation about Database and Database Administrator
abhishekchauhan86963
Β 
slidesgo-unlocking-the-code-the-dynamic-dance-of-variables-and-constants-2024...
kr2589474
Β 
Applitools Platform Pulse: What's New and What's Coming - July 2025
Applitools
Β 
ChatPharo: an Open Architecture for Understanding How to Talk Live to LLMs
ESUG
Β 
Enhancing Healthcare RPM Platforms with Contextual AI Integration
Cadabra Studio
Β 
Web Testing.pptx528278vshbuqffqhhqiwnwuq
studylike474
Β 
On Software Engineers' Productivity - Beyond Misleading Metrics
RomΓ©n RodrΓ­guez-Gil
Β 
New Download MiniTool Partition Wizard Crack Latest Version 2025
imang66g
Β 
What to consider before purchasing Microsoft 365 Business Premium_PDF.pdf
Q-Advise
Β 
lesson-2-rules-of-netiquette.pdf.bshhsjdj
jasmenrojas249
Β 
Visualising Data with Scatterplots in IBM SPSS Statistics.pptx
Version 1 Analytics
Β 
Maximizing Revenue with Marketo Measure: A Deep Dive into Multi-Touch Attribu...
bbedford2
Β 
Immersive experiences: what Pharo users do!
ESUG
Β 
Activate_Methodology_Summary presentatio
annapureddyn
Β 
Generating Union types w/ Static Analysis
K. Matthew Dupree
Β 
The-Dawn-of-AI-Reshaping-Our-World.pptxx
parthbhanushali307
Β 
MiniTool Power Data Recovery Crack New Pre Activated Version Latest 2025
imang66g
Β 
Key Features to Look for in Arizona App Development Services
Net-Craft.com
Β 
advancepresentationskillshdhdhhdhdhdhhfhf
jasmenrojas249
Β 
WatchTraderHub - Watch Dealer software with inventory management and multi-ch...
WatchDealer Pavel
Β 
Presentation about Database and Database Administrator
abhishekchauhan86963
Β 

Java 9 Modules: The Duke Yet Lives That OSGi Shall Depose