IBM Runtime TechnologiesIBM Runtime Technologies
Modularizing AcmeAirDinakar Guniguntala (@dinogun)
Sabari Krishnamoorthy (@devi__krish)
OpenJ9 Cloud Squad, Bangalore
IBM Runtime TechnologiesIBM Runtime Technologies
2
Agenda

Why Modularity ?

Modularity Goals

What is AcmeAir

Applying modularity to AcmeAir

Summary
IBM Runtime TechnologiesIBM Runtime Technologies
3
Why Modularity ?
IBM Runtime TechnologiesIBM Runtime Technologies
4
Classpath/jar Hell
●
The same class is
available from two or
more jar files.
●
These classes may have
been pulled in
automatically from the
build tool when trying
to resolve
dependencies.
●
The two versions may
behave differently.
IBM Runtime TechnologiesIBM Runtime Technologies
5
Security/Footprint

Typical JRE size is around
~200MB - 250MB

The JRE carries a lot of legacy
code.

The percentage of code from
the JRE that is actually used by
any application is very small
compared to the functionality
packaged in the JRE.

No easy way to reduce the size
of the JRE.

TCK compliance is another
aspect to be considered while
chopping the JRE to suit one's
need.
IBM Runtime TechnologiesIBM Runtime Technologies
6
Modularity Goals
IBM Runtime TechnologiesIBM Runtime Technologies
7
Modularity Goals

Strong Encapsulation
– Only expose the interfaces that are to be used by external modules.
– Internal implementation details are truly hidden.

Reliable configuration
– Module system makes it easy to understand the dependencies and the interfaces exported.
– Compile and runtime dependency checks reduces run-time errors.

Security
– No longer possible to access internal classes, helps reduce vulnerabilities.

Footprint optimization
– Jlink helps to package only those modules that are needed. Greatly reduces the size of the runtime.
IBM Runtime TechnologiesIBM Runtime Technologies
8
Modular Java 9 JDK
IBM Runtime TechnologiesIBM Runtime Technologies
9
AcmeAir
A Fictitious Airline
IBM Runtime TechnologiesIBM Runtime Technologies
10
AcmeAir – Non-modular layout
acmeair-services
acmeair-mongo-servicesacmeair-loader
javaee-web-api
json-simple
mongo-java-driver
bson
acmeair-ss
(Support Service)
acmeair-mainapp
(Web) acmeair-bs
(Booking Service)
acmeair-fs
(Flight Service)
acmeair-cs
(Customer Service)
Maven Repo
acmeair-as
(Authentication)
IBM Runtime TechnologiesIBM Runtime Technologies
11
Demo
(https://github.com/ibmruntimes/acmeair-modular)
IBM Runtime TechnologiesIBM Runtime Technologies
12
Related Links

Related JEPs and JSRs

http://openjdk.java.net/projects/jigsaw/
– 200: The Modular JDK → http://openjdk.java.net/jeps/200
– 201: The modular source code → http://openjdk.java.net/jeps/201
– 220: The modular Run-Time images → http://openjdk.java.net/jeps/220
– 260: Encapsulate most internal APIs → http://openjdk.java.net/jeps/260
– 261: Module System → http://openjdk.java.net/jeps/261
– 282: jlink: The java linker → http://openjdk.java.net/jeps/282

Gradle modularity changes
– https://guides.gradle.org/building-java-9-modules/
– https://discuss.gradle.org/t/modularity-support-with-gradle/22445

Modularizing AcmeAir: A case study in modularizing a Java App

  • 1.
    IBM Runtime TechnologiesIBMRuntime Technologies Modularizing AcmeAirDinakar Guniguntala (@dinogun) Sabari Krishnamoorthy (@devi__krish) OpenJ9 Cloud Squad, Bangalore
  • 2.
    IBM Runtime TechnologiesIBMRuntime Technologies 2 Agenda  Why Modularity ?  Modularity Goals  What is AcmeAir  Applying modularity to AcmeAir  Summary
  • 3.
    IBM Runtime TechnologiesIBMRuntime Technologies 3 Why Modularity ?
  • 4.
    IBM Runtime TechnologiesIBMRuntime Technologies 4 Classpath/jar Hell ● The same class is available from two or more jar files. ● These classes may have been pulled in automatically from the build tool when trying to resolve dependencies. ● The two versions may behave differently.
  • 5.
    IBM Runtime TechnologiesIBMRuntime Technologies 5 Security/Footprint  Typical JRE size is around ~200MB - 250MB  The JRE carries a lot of legacy code.  The percentage of code from the JRE that is actually used by any application is very small compared to the functionality packaged in the JRE.  No easy way to reduce the size of the JRE.  TCK compliance is another aspect to be considered while chopping the JRE to suit one's need.
  • 6.
    IBM Runtime TechnologiesIBMRuntime Technologies 6 Modularity Goals
  • 7.
    IBM Runtime TechnologiesIBMRuntime Technologies 7 Modularity Goals  Strong Encapsulation – Only expose the interfaces that are to be used by external modules. – Internal implementation details are truly hidden.  Reliable configuration – Module system makes it easy to understand the dependencies and the interfaces exported. – Compile and runtime dependency checks reduces run-time errors.  Security – No longer possible to access internal classes, helps reduce vulnerabilities.  Footprint optimization – Jlink helps to package only those modules that are needed. Greatly reduces the size of the runtime.
  • 8.
    IBM Runtime TechnologiesIBMRuntime Technologies 8 Modular Java 9 JDK
  • 9.
    IBM Runtime TechnologiesIBMRuntime Technologies 9 AcmeAir A Fictitious Airline
  • 10.
    IBM Runtime TechnologiesIBMRuntime Technologies 10 AcmeAir – Non-modular layout acmeair-services acmeair-mongo-servicesacmeair-loader javaee-web-api json-simple mongo-java-driver bson acmeair-ss (Support Service) acmeair-mainapp (Web) acmeair-bs (Booking Service) acmeair-fs (Flight Service) acmeair-cs (Customer Service) Maven Repo acmeair-as (Authentication)
  • 11.
    IBM Runtime TechnologiesIBMRuntime Technologies 11 Demo (https://github.com/ibmruntimes/acmeair-modular)
  • 12.
    IBM Runtime TechnologiesIBMRuntime Technologies 12 Related Links  Related JEPs and JSRs  http://openjdk.java.net/projects/jigsaw/ – 200: The Modular JDK → http://openjdk.java.net/jeps/200 – 201: The modular source code → http://openjdk.java.net/jeps/201 – 220: The modular Run-Time images → http://openjdk.java.net/jeps/220 – 260: Encapsulate most internal APIs → http://openjdk.java.net/jeps/260 – 261: Module System → http://openjdk.java.net/jeps/261 – 282: jlink: The java linker → http://openjdk.java.net/jeps/282  Gradle modularity changes – https://guides.gradle.org/building-java-9-modules/ – https://discuss.gradle.org/t/modularity-support-with-gradle/22445