java modules using project jigsaw@jdk 9

21
Project Jigsaw@JDK 9 Mauricio “Maltron” Leal [email protected] April/2016

Upload: mauricio-maltron-leal

Post on 16-Apr-2017

384 views

Category:

Software


0 download

TRANSCRIPT

Page 1: Java modules using project jigsaw@jdk 9

Project Jigsaw@JDK 9Mauricio “Maltron” [email protected]/2016

Page 2: Java modules using project jigsaw@jdk 9

Ever-growing and Indivisible Java Runtime

• Java runtime has always been growing in size.• Java 8 there was no way to install a subset of the JRE.• All Java installations were distributed with libraries for such

API’s as XML, SQL and Swing (whether you needed them or not).

• Significant for medium sized computing devices: Routers, TV-boxes, cars and other tiny nooks and crannies.

• Containers also gains new relevance on servers: Reducing an image’s footprint will reduce costs.

• Java 8: Compact Profiles

Page 3: Java modules using project jigsaw@jdk 9

Roadmap for JDK 9

26/May/2016 Feature Complete11/August/2016 All Tests Run01/September/2016 Rampdown Start20/October/2016 Zero Bug Bounce01/December/2016 Rampdown Phase 226/January/2017 Final Release Candidate

http://openjdk.java.net/projects/jdk9/

23/Março/2017 General Availability

Page 4: Java modules using project jigsaw@jdk 9

Class CountryClass State

Class City

firstfile.jar

depends

Class World

Java Today: No Encapsulation

Country c = new Country();State s = new State();City a = new City();

Page 5: Java modules using project jigsaw@jdk 9

Class World

Java Today: Unexpressed Dependencies

?Problem will rise during runtime: NoClassDefFoundError

Country c = new Country();

Page 6: Java modules using project jigsaw@jdk 9

Class CountryClass State

Class City

firstfile.jar

depends

Class World

Java Today: Shadowing

?Country c = new Country();

secondfile.jar

Class Country

depends

Class Territory

Class County

Page 7: Java modules using project jigsaw@jdk 9

Class CountryClass State

Class City

firstfile.jar

secondfile.jar

Class CountryClass Territory

Class County

depends

depends

Country c = new Country();Class World

Java Today: Unexpressed Dependencies

?

Page 8: Java modules using project jigsaw@jdk 9

Class Country1.0

firstfile.jar

secondfile.jar

Class Country2.0

depends

depends

Country c = new Country();Class World

Java Today: Version Collisions

?

Page 9: Java modules using project jigsaw@jdk 9

Class World

Java Today: Startup Performance

Java runtime has loaded and JIT compiled all required classes.

Executes a linear scan of all JARs on the classpath

Identifying all occurrences of a specific annotation requires the inspection of all classes on the classpath

Page 10: Java modules using project jigsaw@jdk 9

Project JigsawJSR 376: Java Platform Module System

Page 11: Java modules using project jigsaw@jdk 9

Project Jigsaw

1Make the Java

SE Platform and the JDK, more easily scalable down to small

computing devices

2Improve security

and maintainability of Java SE Platform Implementations in

general, and the JDK in particular

3Enable improved

application performance

4Make it easier for

developers to construct and

maintain libraries and large

applications, for both Java SE and

EE Platforms.

Page 12: Java modules using project jigsaw@jdk 9

[Modules] are named, self-describing program components consisting of code and data. A module must be able to contain Java classes and interfaces, as organized into packages, and also native code, in the form of dynamically-loaded libraries. A module’s data must be able to contain static resources files and user-editable configuration files.

Page 13: Java modules using project jigsaw@jdk 9

Class CountryClass State

Class City

firstfile.jar

depends

Class World

Java 9: Strong Encapsulation

module com.example { exports com.example;} module-info

Country c = new Country();

City a = new City();State s = new State();

Page 14: Java modules using project jigsaw@jdk 9

Class CountryClass State

Class City

firstfile.jar

depends

Country c = new Country();State s = new State();City a = new City();

Class World

Java 9: Improved Security and Maintainability

module com.example { exports com.example;} module-info

Critical code is now effectively hidden from code that does not need to use it. It also makes maintenance easier as a

module’s public API can more easily be kept small.

Page 15: Java modules using project jigsaw@jdk 9

Java 9: Improved Performance

Page 16: Java modules using project jigsaw@jdk 9

Java 9: Improved Performance

Existing optimization techniques can be used more effectively.

Page 17: Java modules using project jigsaw@jdk 9

Java 9: Improved Performance

No distinction between JDK and JRE

Page 18: Java modules using project jigsaw@jdk 9

Java 9: Scalable Platform

This will help maintain Java’s position as a key player for small devices as well as for containers

Page 19: Java modules using project jigsaw@jdk 9

Java 9: Reliable Configuration

Ability to analyze these dependencies at compile-time, build-time and launch-time.

Page 20: Java modules using project jigsaw@jdk 9

DEMO

Page 21: Java modules using project jigsaw@jdk 9