SlideShare a Scribd company logo
Stephan Herrmann
Supporting Java™ 9 in Eclipse
—
A critical perspective
J
D
T
Simply Retail.
2
J
D
T
Stephan Herrmann @Eclipse Day India 2018 – published under the EPL
Supporting Java™ 9 in Eclipse
A Play in 4 Acts
3
J
D
T
Stephan Herrmann @Eclipse Day India 2018 – published under the EPL
Act 1
What is Jigsaw all about?
That's simple and easy!That's simple and easy!
4
J
D
T
Stephan Herrmann @Eclipse Day India 2018 – published under the EPL
Simple: Module Syntax vs. OSGi Manifest
module org.m1 { …
requires org.m2;
requires transitive org.m3;
exports org.pack1;
exports org.pack2 to org.m2;
provides org.Ifc with org.Impl;
uses org.Ifc;
Bundle-SymbolicName: org.m1
Require-Bundle: org.m2
org.m3;visibility:=reexport
Export-Package: org.pack1
org.pack2;x-friends=”org.m2”
service.xml
module-info.java MANIFEST.MF
<scr:component
xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0"
name="IMyService">
<implementation class="org.Impl"/>
<service>
<provide interface="org.Ifc"/>
</service>
</scr:component>
5
J
D
T
Stephan Herrmann @Eclipse Day India 2018 – published under the EPL
Act 1: That's simple and easy!
DEMO: Modules in Eclipse
6
J
D
T
Stephan Herrmann @Eclipse Day India 2018 – published under the EPL
Act 2
A closer look at module-info
–
from a tool smith's perspective
Expect a slight
sense of surprise
Expect a slight
sense of surprise
8
J
D
T
Stephan Herrmann @Eclipse Day India 2018 – published under the EPL
Act 2: Something's weird
JDT API (1):
org.eclipse.jdt.core.ToolFactory.createScanner(..)
org.eclipse.jdt.core.compiler.IScanner
●
void resetTo(int startPosition, int endPosition)
●
int getNextToken()
org.eclipse.jdt.core.compiler.ITerminalSymbols.TokenNameIdentifer
In Java 9 this API is beyond repair
restricted keywords:
●
“keywords that are keywords when they are keywords, else identifers” [my words]
●
classifcation keyword / identifer happens after parsing
should we remove this API (and break all clients of JDT)?
just hope that nobody will use it for module-info.java?
9
J
D
T
Stephan Herrmann @Eclipse Day India 2018 – published under the EPL
Act 2: Something's weird
JDT API (1):
org.eclipse.jdt.core.ToolFactory.createScanner(..)
org.eclipse.jdt.core.compiler.IScanner
●
void resetTo(int startPosition, int endPosition)
●
int getNextToken()
org.eclipse.jdt.core.compiler.ITerminalSymbols.TokenNameIdentifer
In Java 9 this API is beyond repair
restricted keywords:
●
“keywords that are keywords when they are keywords, else identifers” [my words]
●
classifcation keyword / identifer happens after parsing
should we remove this API (and break all clients of JDT)?
just hope that nobody will use it for module-info.java?
import to.uses;
import to.module;
import to.to;
module module {
requires requires;
exports to to exports;
uses module;
provides uses with to;
requires transitive transitive;
}
import to.uses;
import to.module;
import to.to;
module module {
requires requires;
exports to to exports;
uses module;
provides uses with to;
requires transitive transitive;
}
11
J
D
T
Stephan Herrmann @Eclipse Day India 2018 – published under the EPL
Act 2: Something's weird
Updating Tools Java™ 8 Java→ ™ 9
cannot be done in a compatible way
12
J
D
T
Stephan Herrmann @Eclipse Day India 2018 – published under the EPL
Act 3
There is complexity
—
Questions:
What is the meaning of a.b.C1?
Is the reference a.b.C1 legal?
Does Java 9 support split packages?
14
J
D
T
Stephan Herrmann @Eclipse Day India 2018 – published under the EPL
Act 3: Concepts
How we want to see the world:
Module 1
package a
C1 C2C0
package a.b
C1 C3
Module 2
package a.c
C1 C2
package a.b
C1 C4
requires
15
J
D
T
Stephan Herrmann @Eclipse Day India 2018 – published under the EPL
Act 3: Realization
This is the world according to JLS:
Module 1 Module 2
C1
CU1
C0
associated with
CU2
C2
package a
declares
package bis member
within
CU1
C1
CU1
C1
package c
CU2
C2
requires
exports
16
J
D
T
Stephan Herrmann @Eclipse Day India 2018 – published under the EPL
Act 3: unnecessary complexity
Containment
module
package
class
Independent
packages among each other
Module 1
package a
C1 C2C0
package a.b
C1 C3
Module 2
package a.c
C1 C2
package a.b
C1 C4
requires
Emulation by indirect relations
cu is associated to module
cu declares package
cu contains class
Containment
package
sub-package
Mod-
ule 1
Mod-
ule 2C1
C0
CU1
C2
CU2
package a
package b
C1
CU1 CU1
C1
package c
C2
CU2
requires
17
J
D
T
Stephan Herrmann @Eclipse Day India 2018 – published under the EPL
Act 3: Putting it to work
Inside Module2, what does a.b.C1 mean?
a.b.C1 is found in the CU1 associated with Module2
package a.b is uniquely visible from Module2
Module 1 Module 2
C1
CU1
C0CU2
C2
package a
package b
CU1
C1
CU1
C1
package c
CU2
C2
requires
package b
✔
✔
package a
18
J
D
T
Stephan Herrmann @Eclipse Day India 2018 – published under the EPL
Act 3: Putting it to work
Inside Module2, what does a.b.C1 mean?
package a.b is not uniquely visible, could be from Module1 or from Module2
this confguration is illegal
Module 1 Module 2
C1
CU1
C0CU2
C2
package a
package b
CU1
C1
CU1
C1
package c
CU2
C2
requires
CUX
X
19
J
D
T
Stephan Herrmann @Eclipse Day India 2018 – published under the EPL
Act 3: Legal but broken
Module 1 Module 2
C1
CU1
C0CU2
C2
package a
package b
CU1
C1
CU1
C1
package c
CU2
C2
requires
$ java -m Module2
Error occurred during initialization of boot layer
java.lang.LayerInstantiationException: Package a.b in both module Module1 and module Module2
$ _
Need a Layer implementation
that is capable of classloader-based isolation.
Need a Layer implementation
that is capable of classloader-based isolation.
20
J
D
T
Stephan Herrmann @Eclipse Day India 2018 – published under the EPL
Act 3: Legal but asking for trouble
API Leak
API mentions a type, which the client cannot mention
legal
new complexity in the implementation
put overloading and inheritance in the mix: infnite supply of new Java puzzlers
Module 1 Module 2
C1
CU1
C0CU2
C2
package a
package b
CU1
C1
CU1
C1
package c
CU2
C2
requires
public void doSomething(a.b.C1 arg) { … }public void doSomething(a.b.C1 arg) { … }
21
J
D
T
Stephan Herrmann @Eclipse Day India 2018 – published under the EPL
Act 3: Legal but asking for trouble
API Leak
API mentions a type, which the client cannot mention
legal
new complexity in the implementation
put overloading and inheritance in the mix: infnite supply of new Java puzzlers
Module 1 Module 2
C1
CU1
C0CU2
C2
package a
package b
CU1
C1
CU1
C1
package c
CU2
C2
requires
public void doSomething(a.b.C1 arg) { … }public void doSomething(a.b.C1 arg) { … }
Missed Opportunity
●
API leaks should be illegal
●
Or method should be unmentionable for clients
Missed Opportunity
●
API leaks should be illegal
●
Or method should be unmentionable for clients
22
J
D
T
Stephan Herrmann @Eclipse Day India 2018 – published under the EPL
Act 3: summary encapsulation
Split packages
concealed: legal
●
but no promise that the runtime can handle it
●
need a capable Layer implementation
merging a package (like fragment & host bundle) is illegal
●
even if no class-level confict is involved
API leaks
JLS is silent
compilers issue warnings
●
TODO: better coordinate warnings between compilers
25
J
D
T
Stephan Herrmann @Eclipse Day India 2018 – published under the EPL
Act 3: There is Complexity
End of Act 3
A simple surface
realized by complexity
26
J
D
T
Stephan Herrmann @Eclipse Day India 2018 – published under the EPL
Act 4
There's a lot more:
command line options
–illegal-access={permit,warn,debug,deny}
28
J
D
T
Stephan Herrmann @Eclipse Day India 2018 – published under the EPL
Act 4: Manipulating the Module Graph
Things you can change via CLI options
Add / remove / replace a module
Add a “reads” edge (“requires”)
Expose a package
●
compile time (“exports”)
●
runtime (“opens”)
Merge a module from several sources
●
patching
...
29
J
D
T
Stephan Herrmann @Eclipse Day India 2018 – published under the EPL
Act 4: Options
Let's map command line options
to UI
30
J
D
T
Stephan Herrmann @Eclipse Day India 2018 – published under the EPL
Act 4: Options
“Is modular”
Edit: enter the rabbit hole
31
J
D
T
Stephan Herrmann @Eclipse Day India 2018 – published under the EPL
Act 4: Options
“Is modular”
Edit: enter the rabbit hole
Contents
what you ask for
what you get
--limit-modules, --add-modules
default as per JEP 261
32
J
D
T
Stephan Herrmann @Eclipse Day India 2018 – published under the EPL
Act 4: Options
“Is modular”
Edit: enter the rabbit hole
Contents
what you ask for
what you get
--limit-modules, --add-modules
default as per JEP 261
Details
--add-exports
--add-reads (rarely needed)
--patch-module (careful!)
33
J
D
T
Stephan Herrmann @Eclipse Day India 2018 – published under the EPL
Act 4: Options
“Is modular”
Edit: enter the rabbit hole
Contents
what you ask for
what you get
--limit-modules, --add-modules
default as per JEP 261
Details
--add-exports
--add-reads (rarely needed)
--patch-module (careful!)
Power switch
34
J
D
T
Stephan Herrmann @Eclipse Day India 2018 – published under the EPL
Act 4: Options
Build vs. Run
UI should be sufcient for building
●
No need to learn cryptic CLI
Sufcient information for running?
Show Command Line
New in 2018-09
35
J
D
T
Stephan Herrmann @Eclipse Day India 2018 – published under the EPL
Act 4: Options
Build vs. Run
UI should be sufcient for building
●
No need to learn cryptic CLI
Sufcient information for running?
Show Command Line
New in 2018-09
Override Dependencies
New in Photon
36
J
D
T
Stephan Herrmann @Eclipse Day India 2018 – published under the EPL
Act 4: Options
Build vs. Run
UI should be sufcient for building
●
No need to learn cryptic CLI
Sufcient information for running?
Show Command Line
New in 2018-09
Override Dependencies
New in Photon
More UI
… work in progress ...
37
J
D
T
Stephan Herrmann @Eclipse Day India 2018 – published under the EPL
Epilogue
Act 4: Modifying Encapsulation?
“Gradual Encapsulation” [Herrmann 2008]
●
is encapsulation your friend or foe?
●
enforce encapsulation?
●
rules entail exceptions
Act 3: Isolation?
Separate namespace per module?
●
partly achieved / emulated
●
several opportunities missed
Act 2: Compatibility?
Java 9 is disruptive
●
against frameworks and applications
●
against tools
38
J
D
T
Stephan Herrmann @Eclipse Day India 2018 – published under the EPL
Epilogue
Act 4: Modifying Encapsulation?
“Gradual Encapsulation” [Herrmann 2008]
●
is encapsulation your friend or foe?
●
enforce encapsulation?
●
rules entail exceptions
Act 3: Isolation?
Separate namespace per module?
●
partly achieved / emulated
●
several opportunities missed
Act 2: Compatibility?
Java 9 is disruptive
●
against frameworks and applications
●
against tools
@NonNullByDefault
module org.eclipse.mymodule {
…
}
@NonNullByDefault
module org.eclipse.mymodule {
…
}

More Related Content

What's hot (10)

PDF
Refactoring a go project
Dan Tran
 
PPTX
Golang presentaion-2018-07-26
Shintaro Ikeda
 
PDF
Android and OSGi Can They Work Together - BJ Hargrave & Neil Bartlett
mfrancis
 
PPT
Open-DO Update
AdaCore
 
ODP
Android NDK Overview
Badrinath Kulkarni
 
PPTX
Hacking for Fun and Profit
Apkudo
 
PPTX
Hacking for Fun and Profit (Mostly for Fun). AnDevCon Boston
Apkudo
 
ODP
QVT Traceability: What does it really mean?
Edward Willink
 
PDF
Who Needs Thumbs? Reverse Engineering Scramble With Friends
Apkudo
 
PPTX
D8 Dexer
Phani Kumar Gullapalli
 
Refactoring a go project
Dan Tran
 
Golang presentaion-2018-07-26
Shintaro Ikeda
 
Android and OSGi Can They Work Together - BJ Hargrave & Neil Bartlett
mfrancis
 
Open-DO Update
AdaCore
 
Android NDK Overview
Badrinath Kulkarni
 
Hacking for Fun and Profit
Apkudo
 
Hacking for Fun and Profit (Mostly for Fun). AnDevCon Boston
Apkudo
 
QVT Traceability: What does it really mean?
Edward Willink
 
Who Needs Thumbs? Reverse Engineering Scramble With Friends
Apkudo
 

Similar to Supporting Java™ 9 in Eclipse - A critical perspective - Stephan Herrmann (20)

PPTX
Java 9 Module System Introduction
Dan Stine
 
PDF
Eclipse Day India 2015 - Keynote - Stephan Herrmann
Eclipse Day India
 
PPTX
Apache Maven supports all Java (JokerConf 2018)
Robert Scholte
 
PDF
Java SE 9 modules - an introduction (July 2018)
Stephen Colebourne
 
PPTX
Apache maven and its impact on java 9 (Java One 2017)
Robert Scholte
 
PPTX
Modern Java Workshop
Simon Ritter
 
PPTX
Getting started with Java 9 modules
Rafael Winterhalter
 
PDF
Java 9, JShell, and Modularity
Mohammad Hossein Rimaz
 
PDF
Java SE 9 modules (JPMS) - an introduction
Stephen Colebourne
 
PPTX
Preparing for java 9 modules upload
Ryan Cuprak
 
PPTX
Java Platform Module System
Vignesh Ramesh
 
PDF
Jigsaw what the Heck Happens Now - N Bartlett
mfrancis
 
PPTX
Java 9: Deep Dive into Modularity and Dealing with Migration Issues
GlobalLogic Ukraine
 
PPTX
The do's and don'ts with java 9 (Devoxx 2017)
Robert Scholte
 
PDF
Java 9 preview
Ivan Krylov
 
PDF
What we can expect from Java 9 by Ivan Krylov
J On The Beach
 
PDF
Haj 4344-java se 9 and the application server-1
Kevin Sutter
 
PDF
JavaOne 2016: Life after Modularity
DanHeidinga
 
PPTX
S/W Design and Modularity using Maven
Scheidt & Bachmann
 
PDF
Eclipse In Action A Guide For Java Developers 1st Edition David Gallardo
spatzoachskq
 
Java 9 Module System Introduction
Dan Stine
 
Eclipse Day India 2015 - Keynote - Stephan Herrmann
Eclipse Day India
 
Apache Maven supports all Java (JokerConf 2018)
Robert Scholte
 
Java SE 9 modules - an introduction (July 2018)
Stephen Colebourne
 
Apache maven and its impact on java 9 (Java One 2017)
Robert Scholte
 
Modern Java Workshop
Simon Ritter
 
Getting started with Java 9 modules
Rafael Winterhalter
 
Java 9, JShell, and Modularity
Mohammad Hossein Rimaz
 
Java SE 9 modules (JPMS) - an introduction
Stephen Colebourne
 
Preparing for java 9 modules upload
Ryan Cuprak
 
Java Platform Module System
Vignesh Ramesh
 
Jigsaw what the Heck Happens Now - N Bartlett
mfrancis
 
Java 9: Deep Dive into Modularity and Dealing with Migration Issues
GlobalLogic Ukraine
 
The do's and don'ts with java 9 (Devoxx 2017)
Robert Scholte
 
Java 9 preview
Ivan Krylov
 
What we can expect from Java 9 by Ivan Krylov
J On The Beach
 
Haj 4344-java se 9 and the application server-1
Kevin Sutter
 
JavaOne 2016: Life after Modularity
DanHeidinga
 
S/W Design and Modularity using Maven
Scheidt & Bachmann
 
Eclipse In Action A Guide For Java Developers 1st Edition David Gallardo
spatzoachskq
 
Ad

More from Eclipse Day India (20)

PPTX
Java Performance Testing for Everyone - Shelley Lambert
Eclipse Day India
 
PDF
Eclipse IDE Tips and Tricks - Lakshmi Priya Shanmugam
Eclipse Day India
 
PDF
Pattern Matching in Java - Srikanth Sankaran
Eclipse Day India
 
PDF
Machine Learning for Java Developers - Nasser Ebrahim
Eclipse Day India
 
PPTX
Scaling Eclipse on HiDPI Monitors - Niraj Modi
Eclipse Day India
 
PPTX
Please Behave Yourself: BDD and automating Eclipse RCP applications using JBe...
Eclipse Day India
 
PDF
Eclipse Day India 2015 - Rest with Java (jax rs) and jersey
Eclipse Day India
 
PDF
Eclipse Day India 2015 - Java bytecode analysis and JIT
Eclipse Day India
 
PPTX
Eclipse Day India 2015 - Java 8 Overview
Eclipse Day India
 
ODP
Eclipse Day India 2015 - Java 9
Eclipse Day India
 
PDF
Eclipse Day India 2015 - Eclipse RCP testing using Jubula based automation
Eclipse Day India
 
PDF
Eclipse Day India 2015 - Oomph
Eclipse Day India
 
PDF
Eclipse Day India 2015 - Keynote (Mike Milinkovich)
Eclipse Day India
 
PDF
Eclipse Day India 2015 - Unleashing the Java 8 Tooling in Eclipse
Eclipse Day India
 
PDF
IDS and Bluemix
Eclipse Day India
 
PPT
SWT - Technical Deep Dive
Eclipse Day India
 
PPTX
PDE builds or Maven
Eclipse Day India
 
PPT
Orion - IDE on the cloud
Eclipse Day India
 
PDF
JDT embraces lambda expressions
Eclipse Day India
 
Java Performance Testing for Everyone - Shelley Lambert
Eclipse Day India
 
Eclipse IDE Tips and Tricks - Lakshmi Priya Shanmugam
Eclipse Day India
 
Pattern Matching in Java - Srikanth Sankaran
Eclipse Day India
 
Machine Learning for Java Developers - Nasser Ebrahim
Eclipse Day India
 
Scaling Eclipse on HiDPI Monitors - Niraj Modi
Eclipse Day India
 
Please Behave Yourself: BDD and automating Eclipse RCP applications using JBe...
Eclipse Day India
 
Eclipse Day India 2015 - Rest with Java (jax rs) and jersey
Eclipse Day India
 
Eclipse Day India 2015 - Java bytecode analysis and JIT
Eclipse Day India
 
Eclipse Day India 2015 - Java 8 Overview
Eclipse Day India
 
Eclipse Day India 2015 - Java 9
Eclipse Day India
 
Eclipse Day India 2015 - Eclipse RCP testing using Jubula based automation
Eclipse Day India
 
Eclipse Day India 2015 - Oomph
Eclipse Day India
 
Eclipse Day India 2015 - Keynote (Mike Milinkovich)
Eclipse Day India
 
Eclipse Day India 2015 - Unleashing the Java 8 Tooling in Eclipse
Eclipse Day India
 
IDS and Bluemix
Eclipse Day India
 
SWT - Technical Deep Dive
Eclipse Day India
 
PDE builds or Maven
Eclipse Day India
 
Orion - IDE on the cloud
Eclipse Day India
 
JDT embraces lambda expressions
Eclipse Day India
 
Ad

Recently uploaded (20)

PPTX
UI5Con 2025 - Beyond UI5 Controls with the Rise of Web Components
Wouter Lemaire
 
PDF
OpenInfra ID 2025 - Are Containers Dying? Rethinking Isolation with MicroVMs.pdf
Muhammad Yuga Nugraha
 
PPTX
python advanced data structure dictionary with examples python advanced data ...
sprasanna11
 
PPTX
UI5Con 2025 - Get to Know Your UI5 Tooling
Wouter Lemaire
 
PPTX
Earn Agentblazer Status with Slack Community Patna.pptx
SanjeetMishra29
 
PDF
"Effect, Fiber & Schema: tactical and technical characteristics of Effect.ts"...
Fwdays
 
PDF
Meetup Kickoff & Welcome - Rohit Yadav, CSIUG Chairman
ShapeBlue
 
PPTX
Machine Learning Benefits Across Industries
SynapseIndia
 
PDF
2025-07-15 EMEA Volledig Inzicht Dutch Webinar
ThousandEyes
 
PDF
Novus Safe Lite- What is Novus Safe Lite.pdf
Novus Hi-Tech
 
PDF
The Past, Present & Future of Kenya's Digital Transformation
Moses Kemibaro
 
PDF
CloudStack GPU Integration - Rohit Yadav
ShapeBlue
 
PDF
Shuen Mei Parth Sharma Boost Productivity, Innovation and Efficiency wit...
AWS Chicago
 
PPTX
Simplifying End-to-End Apache CloudStack Deployment with a Web-Based Automati...
ShapeBlue
 
PDF
Building Resilience with Digital Twins : Lessons from Korea
SANGHEE SHIN
 
PDF
TrustArc Webinar - Data Privacy Trends 2025: Mid-Year Insights & Program Stra...
TrustArc
 
PDF
Arcee AI - building and working with small language models (06/25)
Julien SIMON
 
PDF
HR agent at Mediq: Lessons learned on Agent Builder & Maestro by Tacstone Tec...
UiPathCommunity
 
PPTX
Lecture 5 - Agentic AI and model context protocol.pptx
Dr. LAM Yat-fai (林日辉)
 
PDF
Sustainable and comertially viable mining process.pdf
Avijit Kumar Roy
 
UI5Con 2025 - Beyond UI5 Controls with the Rise of Web Components
Wouter Lemaire
 
OpenInfra ID 2025 - Are Containers Dying? Rethinking Isolation with MicroVMs.pdf
Muhammad Yuga Nugraha
 
python advanced data structure dictionary with examples python advanced data ...
sprasanna11
 
UI5Con 2025 - Get to Know Your UI5 Tooling
Wouter Lemaire
 
Earn Agentblazer Status with Slack Community Patna.pptx
SanjeetMishra29
 
"Effect, Fiber & Schema: tactical and technical characteristics of Effect.ts"...
Fwdays
 
Meetup Kickoff & Welcome - Rohit Yadav, CSIUG Chairman
ShapeBlue
 
Machine Learning Benefits Across Industries
SynapseIndia
 
2025-07-15 EMEA Volledig Inzicht Dutch Webinar
ThousandEyes
 
Novus Safe Lite- What is Novus Safe Lite.pdf
Novus Hi-Tech
 
The Past, Present & Future of Kenya's Digital Transformation
Moses Kemibaro
 
CloudStack GPU Integration - Rohit Yadav
ShapeBlue
 
Shuen Mei Parth Sharma Boost Productivity, Innovation and Efficiency wit...
AWS Chicago
 
Simplifying End-to-End Apache CloudStack Deployment with a Web-Based Automati...
ShapeBlue
 
Building Resilience with Digital Twins : Lessons from Korea
SANGHEE SHIN
 
TrustArc Webinar - Data Privacy Trends 2025: Mid-Year Insights & Program Stra...
TrustArc
 
Arcee AI - building and working with small language models (06/25)
Julien SIMON
 
HR agent at Mediq: Lessons learned on Agent Builder & Maestro by Tacstone Tec...
UiPathCommunity
 
Lecture 5 - Agentic AI and model context protocol.pptx
Dr. LAM Yat-fai (林日辉)
 
Sustainable and comertially viable mining process.pdf
Avijit Kumar Roy
 

Supporting Java™ 9 in Eclipse - A critical perspective - Stephan Herrmann

  • 1. Stephan Herrmann Supporting Java™ 9 in Eclipse — A critical perspective J D T Simply Retail.
  • 2. 2 J D T Stephan Herrmann @Eclipse Day India 2018 – published under the EPL Supporting Java™ 9 in Eclipse A Play in 4 Acts
  • 3. 3 J D T Stephan Herrmann @Eclipse Day India 2018 – published under the EPL Act 1 What is Jigsaw all about? That's simple and easy!That's simple and easy!
  • 4. 4 J D T Stephan Herrmann @Eclipse Day India 2018 – published under the EPL Simple: Module Syntax vs. OSGi Manifest module org.m1 { … requires org.m2; requires transitive org.m3; exports org.pack1; exports org.pack2 to org.m2; provides org.Ifc with org.Impl; uses org.Ifc; Bundle-SymbolicName: org.m1 Require-Bundle: org.m2 org.m3;visibility:=reexport Export-Package: org.pack1 org.pack2;x-friends=”org.m2” service.xml module-info.java MANIFEST.MF <scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="IMyService"> <implementation class="org.Impl"/> <service> <provide interface="org.Ifc"/> </service> </scr:component>
  • 5. 5 J D T Stephan Herrmann @Eclipse Day India 2018 – published under the EPL Act 1: That's simple and easy! DEMO: Modules in Eclipse
  • 6. 6 J D T Stephan Herrmann @Eclipse Day India 2018 – published under the EPL Act 2 A closer look at module-info – from a tool smith's perspective Expect a slight sense of surprise Expect a slight sense of surprise
  • 7. 8 J D T Stephan Herrmann @Eclipse Day India 2018 – published under the EPL Act 2: Something's weird JDT API (1): org.eclipse.jdt.core.ToolFactory.createScanner(..) org.eclipse.jdt.core.compiler.IScanner ● void resetTo(int startPosition, int endPosition) ● int getNextToken() org.eclipse.jdt.core.compiler.ITerminalSymbols.TokenNameIdentifer In Java 9 this API is beyond repair restricted keywords: ● “keywords that are keywords when they are keywords, else identifers” [my words] ● classifcation keyword / identifer happens after parsing should we remove this API (and break all clients of JDT)? just hope that nobody will use it for module-info.java?
  • 8. 9 J D T Stephan Herrmann @Eclipse Day India 2018 – published under the EPL Act 2: Something's weird JDT API (1): org.eclipse.jdt.core.ToolFactory.createScanner(..) org.eclipse.jdt.core.compiler.IScanner ● void resetTo(int startPosition, int endPosition) ● int getNextToken() org.eclipse.jdt.core.compiler.ITerminalSymbols.TokenNameIdentifer In Java 9 this API is beyond repair restricted keywords: ● “keywords that are keywords when they are keywords, else identifers” [my words] ● classifcation keyword / identifer happens after parsing should we remove this API (and break all clients of JDT)? just hope that nobody will use it for module-info.java? import to.uses; import to.module; import to.to; module module { requires requires; exports to to exports; uses module; provides uses with to; requires transitive transitive; } import to.uses; import to.module; import to.to; module module { requires requires; exports to to exports; uses module; provides uses with to; requires transitive transitive; }
  • 9. 11 J D T Stephan Herrmann @Eclipse Day India 2018 – published under the EPL Act 2: Something's weird Updating Tools Java™ 8 Java→ ™ 9 cannot be done in a compatible way
  • 10. 12 J D T Stephan Herrmann @Eclipse Day India 2018 – published under the EPL Act 3 There is complexity — Questions: What is the meaning of a.b.C1? Is the reference a.b.C1 legal? Does Java 9 support split packages?
  • 11. 14 J D T Stephan Herrmann @Eclipse Day India 2018 – published under the EPL Act 3: Concepts How we want to see the world: Module 1 package a C1 C2C0 package a.b C1 C3 Module 2 package a.c C1 C2 package a.b C1 C4 requires
  • 12. 15 J D T Stephan Herrmann @Eclipse Day India 2018 – published under the EPL Act 3: Realization This is the world according to JLS: Module 1 Module 2 C1 CU1 C0 associated with CU2 C2 package a declares package bis member within CU1 C1 CU1 C1 package c CU2 C2 requires exports
  • 13. 16 J D T Stephan Herrmann @Eclipse Day India 2018 – published under the EPL Act 3: unnecessary complexity Containment module package class Independent packages among each other Module 1 package a C1 C2C0 package a.b C1 C3 Module 2 package a.c C1 C2 package a.b C1 C4 requires Emulation by indirect relations cu is associated to module cu declares package cu contains class Containment package sub-package Mod- ule 1 Mod- ule 2C1 C0 CU1 C2 CU2 package a package b C1 CU1 CU1 C1 package c C2 CU2 requires
  • 14. 17 J D T Stephan Herrmann @Eclipse Day India 2018 – published under the EPL Act 3: Putting it to work Inside Module2, what does a.b.C1 mean? a.b.C1 is found in the CU1 associated with Module2 package a.b is uniquely visible from Module2 Module 1 Module 2 C1 CU1 C0CU2 C2 package a package b CU1 C1 CU1 C1 package c CU2 C2 requires package b ✔ ✔ package a
  • 15. 18 J D T Stephan Herrmann @Eclipse Day India 2018 – published under the EPL Act 3: Putting it to work Inside Module2, what does a.b.C1 mean? package a.b is not uniquely visible, could be from Module1 or from Module2 this confguration is illegal Module 1 Module 2 C1 CU1 C0CU2 C2 package a package b CU1 C1 CU1 C1 package c CU2 C2 requires CUX X
  • 16. 19 J D T Stephan Herrmann @Eclipse Day India 2018 – published under the EPL Act 3: Legal but broken Module 1 Module 2 C1 CU1 C0CU2 C2 package a package b CU1 C1 CU1 C1 package c CU2 C2 requires $ java -m Module2 Error occurred during initialization of boot layer java.lang.LayerInstantiationException: Package a.b in both module Module1 and module Module2 $ _ Need a Layer implementation that is capable of classloader-based isolation. Need a Layer implementation that is capable of classloader-based isolation.
  • 17. 20 J D T Stephan Herrmann @Eclipse Day India 2018 – published under the EPL Act 3: Legal but asking for trouble API Leak API mentions a type, which the client cannot mention legal new complexity in the implementation put overloading and inheritance in the mix: infnite supply of new Java puzzlers Module 1 Module 2 C1 CU1 C0CU2 C2 package a package b CU1 C1 CU1 C1 package c CU2 C2 requires public void doSomething(a.b.C1 arg) { … }public void doSomething(a.b.C1 arg) { … }
  • 18. 21 J D T Stephan Herrmann @Eclipse Day India 2018 – published under the EPL Act 3: Legal but asking for trouble API Leak API mentions a type, which the client cannot mention legal new complexity in the implementation put overloading and inheritance in the mix: infnite supply of new Java puzzlers Module 1 Module 2 C1 CU1 C0CU2 C2 package a package b CU1 C1 CU1 C1 package c CU2 C2 requires public void doSomething(a.b.C1 arg) { … }public void doSomething(a.b.C1 arg) { … } Missed Opportunity ● API leaks should be illegal ● Or method should be unmentionable for clients Missed Opportunity ● API leaks should be illegal ● Or method should be unmentionable for clients
  • 19. 22 J D T Stephan Herrmann @Eclipse Day India 2018 – published under the EPL Act 3: summary encapsulation Split packages concealed: legal ● but no promise that the runtime can handle it ● need a capable Layer implementation merging a package (like fragment & host bundle) is illegal ● even if no class-level confict is involved API leaks JLS is silent compilers issue warnings ● TODO: better coordinate warnings between compilers
  • 20. 25 J D T Stephan Herrmann @Eclipse Day India 2018 – published under the EPL Act 3: There is Complexity End of Act 3 A simple surface realized by complexity
  • 21. 26 J D T Stephan Herrmann @Eclipse Day India 2018 – published under the EPL Act 4 There's a lot more: command line options –illegal-access={permit,warn,debug,deny}
  • 22. 28 J D T Stephan Herrmann @Eclipse Day India 2018 – published under the EPL Act 4: Manipulating the Module Graph Things you can change via CLI options Add / remove / replace a module Add a “reads” edge (“requires”) Expose a package ● compile time (“exports”) ● runtime (“opens”) Merge a module from several sources ● patching ...
  • 23. 29 J D T Stephan Herrmann @Eclipse Day India 2018 – published under the EPL Act 4: Options Let's map command line options to UI
  • 24. 30 J D T Stephan Herrmann @Eclipse Day India 2018 – published under the EPL Act 4: Options “Is modular” Edit: enter the rabbit hole
  • 25. 31 J D T Stephan Herrmann @Eclipse Day India 2018 – published under the EPL Act 4: Options “Is modular” Edit: enter the rabbit hole Contents what you ask for what you get --limit-modules, --add-modules default as per JEP 261
  • 26. 32 J D T Stephan Herrmann @Eclipse Day India 2018 – published under the EPL Act 4: Options “Is modular” Edit: enter the rabbit hole Contents what you ask for what you get --limit-modules, --add-modules default as per JEP 261 Details --add-exports --add-reads (rarely needed) --patch-module (careful!)
  • 27. 33 J D T Stephan Herrmann @Eclipse Day India 2018 – published under the EPL Act 4: Options “Is modular” Edit: enter the rabbit hole Contents what you ask for what you get --limit-modules, --add-modules default as per JEP 261 Details --add-exports --add-reads (rarely needed) --patch-module (careful!) Power switch
  • 28. 34 J D T Stephan Herrmann @Eclipse Day India 2018 – published under the EPL Act 4: Options Build vs. Run UI should be sufcient for building ● No need to learn cryptic CLI Sufcient information for running? Show Command Line New in 2018-09
  • 29. 35 J D T Stephan Herrmann @Eclipse Day India 2018 – published under the EPL Act 4: Options Build vs. Run UI should be sufcient for building ● No need to learn cryptic CLI Sufcient information for running? Show Command Line New in 2018-09 Override Dependencies New in Photon
  • 30. 36 J D T Stephan Herrmann @Eclipse Day India 2018 – published under the EPL Act 4: Options Build vs. Run UI should be sufcient for building ● No need to learn cryptic CLI Sufcient information for running? Show Command Line New in 2018-09 Override Dependencies New in Photon More UI … work in progress ...
  • 31. 37 J D T Stephan Herrmann @Eclipse Day India 2018 – published under the EPL Epilogue Act 4: Modifying Encapsulation? “Gradual Encapsulation” [Herrmann 2008] ● is encapsulation your friend or foe? ● enforce encapsulation? ● rules entail exceptions Act 3: Isolation? Separate namespace per module? ● partly achieved / emulated ● several opportunities missed Act 2: Compatibility? Java 9 is disruptive ● against frameworks and applications ● against tools
  • 32. 38 J D T Stephan Herrmann @Eclipse Day India 2018 – published under the EPL Epilogue Act 4: Modifying Encapsulation? “Gradual Encapsulation” [Herrmann 2008] ● is encapsulation your friend or foe? ● enforce encapsulation? ● rules entail exceptions Act 3: Isolation? Separate namespace per module? ● partly achieved / emulated ● several opportunities missed Act 2: Compatibility? Java 9 is disruptive ● against frameworks and applications ● against tools @NonNullByDefault module org.eclipse.mymodule { … } @NonNullByDefault module org.eclipse.mymodule { … }