java modules using project jigsaw@jdk 9

Post on 16-Apr-2017

383 Views

Category:

Software

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Project Jigsaw@JDK 9Mauricio “Maltron” Lealmaltron@redhat.comApril/2016

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

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

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();

Class World

Java Today: Unexpressed Dependencies

?Problem will rise during runtime: NoClassDefFoundError

Country c = new Country();

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

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

?

Class Country1.0

firstfile.jar

secondfile.jar

Class Country2.0

depends

depends

Country c = new Country();Class World

Java Today: Version Collisions

?

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

Project JigsawJSR 376: Java Platform Module System

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.

[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.

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();

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.

Java 9: Improved Performance

Java 9: Improved Performance

Existing optimization techniques can be used more effectively.

Java 9: Improved Performance

No distinction between JDK and JRE

Java 9: Scalable Platform

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

Java 9: Reliable Configuration

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

DEMO

top related