Agility, Java programming, New technologies and more…
  • rss
  • Home
  • Management
  • Agile Programming
  • Technology
  • Linux
  • Event
  • Android app
  • Contact
  • About the author
  • English
  • Francais

QCon London 2016 – Project Jigsaw in JDK 9 – Modularity comes to Java

Fabian Piau | Thursday April 14th, 2016 - 09:09 PM
  • Print
  • Twitter
  • LinkedIn
  • Facebook
  • Pocket

 Version française disponible

Simon Ritter gave a presentation about JDK 9 at QCon London.

QCon London 2016 - Project Jigsaw in JDK 9 - Modularity comes to Java

QCon London 2016 - Project Jigsaw in JDK 9 - Modularity comes to Java


Java Compatibility Policy

He started with an interesting fact: Java has a general and longstanding compatibility policy.
If an application uses only supported APIs on version N of Java, it should work on version N+1, even without recompilation.
That’s why, to date there are:

  • 23 classes, 18 interfaces and 379 methods that have been deprecated
  • And none have been removed.


JDK 9 brings breaking changes

The JDK has been heavier and heavier over the years. With the version 9, things are going to change. For the first time, JDK 9 will bring incompatibilities.

  • A small number of supported API will be removed
  • The binary structure of the JRE and JDK will change (see details below)
  • It is not allowed to use a single underscore _ as a variable name. It is now a reserved keyword.
  • There will be a new version scheme so that it is easier to distinguish major, minor, and security-update releases, e.g. Java 9.1.2.1. The old versioning format is difficult to understand, e.g. 8h51 and 8u60 are not very meaningful.

The JDK structure is changing. The JRE folder is removed, tools.jar and rt.jar are no longer present, as there was some duplication between them.

Pre-JDK 9 structure

Pre-JDK 9 structure

To have a complete understanding of the pre-JDK 9 structure, you can read JDK 8 and JRE File Structure.

JDK 9 structure

JDK 9 structure

The JDK 9 structure is much cleaner.

JEP 260 proposal is at the heart of JDK 9 and Jigsaw.

The idea is to make most of the JDK’s internal APIs inaccessible by default but leave a few critical, widely-used internal APIs accessible, until supported replacements exist for all or most of their functionality.

The goal is to encapsulate all deprecated API in a module, then eventually getting rid of it in the future (JDK 10?).

Since JDK 8, a command line tool exists to analyze the dependencies of your JAR or class: jdeps. Give it a try! It can be useful to discover if you are using JDK-internal APIs, you should avoid using these dependencies as they may be removed in the future.


Jigsaw and modules

We talk about module just before, but what is it?
Jigsaw brings modularity to the JDK. It makes Java more scalable and flexible, it also improves security, maintainability and performance.
The JDK is split up into modules, and then we take only what we need.

Module

A module is a grouping of code (collection of packages), it can also contain:

  • Native code
  • Resources
  • Configuration data

My first module

To define a module, you need to create a module-info.java file, including (for example):

module com.company.mymodule { 
  requires com.company.myothermodule; 
  requires java.sql; 
}

You can have transitive dependencies (a bit like Maven) thanks to the keyword public.

module java.sql { 
  requires public java.logging; 
}

This means if I have a dependency on the module java.sql, I will have access to all classes included in java.logging (as long as the types are public).

We now have a module dependency graph.

Package visibility

Use of the keyword exports.

module com.company.myothermodule { 
  exports com.company.myothermodule.alpha;  
  exports com.company.myothermodule.beta; 
}

What is exported is visible, by default it’s not!

In Java 9, we have to redefine the keyword public, it comes in different flavours:

  • Public to everyone
  • Public, but only to specific modules
  • Public, only within a module

Public does not mean necessary accessible anymore, that’s a fundamental change.
You can read the Jigsaw specification to know more.

Compilation and execution with module path

Forget about the classpath parameter, there is a new modulepath parameter (or -mp) in the javac / java command line. Its value is one or more directories that contain modules that are required to compile / execute your application.

Also, note there will be default module for the JAR files that are not module-compatible yet (automatic module).

Related posts

Java 11A Java 11 migration successful story IT jobsComputing jobs simplified overview Java EE vs SpringJava EE & CDI vs. Spring springQCon London 2016 – Spring Framework 5 – Preview & Roadmap
Categories
Event
Tags
java, jigsaw, qcon
Comments rss
Comments rss

« QCon London 2016 – Spring Framework 5 – Preview & Roadmap FAQ – Online survey with Google Forms / Drive / Docs »

Download CarmaBlog App

RSS feeds

  • RSS feed RSS - Posts
  • RSS feed RSS - Comments

Most viewed posts

  • Changing the language in Firefox - 116,375 views
  • Using Google Forms / Drive / Docs to create an online survey - 64,403 views
  • FAQ – Online survey with Google Forms / Drive / Docs - 56,247 views
  • Customizing Gnome 3 (Shell) - 30,809 views
  • The meaning of URL, URI, URN - 18,407 views
  • Java EE & CDI vs. Spring - 15,986 views
  • Open Street Map, better map than Google Maps? - 15,800 views
  • Comparing NoSQL: Couchbase & MongoDB - 14,693 views
  • API, REST, JSON, XML, HTTP, URI… What language do you speak? - 13,730 views
  • First steps with Apache Camel - 13,597 views

Recent Comments

  • Fabian Piau on FAQ – Online survey with Google Forms / Drive / DocsOui, dans Google Forms, vous pouvez empêcher les p…
  • BENECH Fabien on FAQ – Online survey with Google Forms / Drive / DocsBonjour, J'ai crée 1 questionnaire via Forms,…
  • SANKARA TIDIANE on Free online MongoDB trainingJ'aimerai suivre
  • Pauline on FAQ – Online survey with Google Forms / Drive / DocsMerci Fabian, mais le but étant que nos clients pu…
  • Fabian Piau on FAQ – Online survey with Google Forms / Drive / DocsProbablement mais ces options sont en général paya…

Recent posts

  • How to write a blog post? At least my way! - 2 years and 5 months ago
  • Bot Attacks: You are not alone… - 4 years and 1 month ago
  • Flagger – Monitor your Canary deployments with Grafana - 4 years and 10 months ago
  • Flagger – Canary deployments on Kubernetes - 5 years and 2 days ago
  • Flagger – Get Started with Istio and Kubernetes - 5 years and 2 weeks ago
  • Expedia CoderDojo in London - 5 years and 9 months ago
  • Volunteering at Devoxx4Kids - 6 years and 2 weeks ago
  • A Java 11 migration successful story - 6 years and 4 months ago
  • Tips to make your WordPress website secure - 6 years and 7 months ago
  • Devoxx UK 2018 – Day 2 - 6 years and 11 months ago
  • Devoxx UK 2018 – Day 1 - 7 years and 12 hours ago
  • Wise, Revolut and Monzo, a small revolution for travelers and expats - 7 years and 3 months ago
  • Autocomplete for Git - 8 years and 1 day ago
  • Swagger, the automated API documentation - 8 years and 2 months ago
  • Microservices architecture – Best practices - 8 years and 7 months ago
Buy me a coffee

Language

  • Français
  • English

Follow me!

Follow me on Linkedin
Follow me on Twitter
Follow me on Stackoverflow
Follow me on Github
Follow me on Rss
Link to my Contact

Email subscription

Enter your email address to receive notifications of new posts.

Tags

.net agile agility android bash best practices blog cache cloud computing conference continuous integration css developer devoxx docker eclipse extreme programming firefox flagger google helm hibernate istio java job jug kubernetes london mobile computing overview performance plugin programmer script security sharing society spring tdd test tool ubuntu windows wordpress

Links

  • Blog Ippon Technologies
  • Blog Publicis Sapient
  • Blog Zenika
  • Classpert
  • CommitStrip
  • Coursera
  • Le Touilleur Express
  • Les Cast Codeurs Podcast
  • OCTO talks !
  • The Twelve-Factor App

Categories

  • Event (15)
  • Linux (3)
  • Management (8)
  • Agile programming (29)
  • Technology (45)

Archives

  • December 2022 (1)
  • April 2021 (1)
  • June 2020 (1)
  • May 2020 (2)
  • July 2019 (1)
  • May 2019 (1)
  • December 2018 (1)
  • October 2018 (1)
  • June 2018 (1)
  • May 2018 (1)
  • January 2018 (1)
  • May 2017 (1)
  • March 2017 (1)
  • October 2016 (1)
  • April 2016 (2)
  • March 2016 (1)
  • November 2015 (1)
  • May 2015 (1)
  • February 2015 (1)
  • December 2014 (1)
  • November 2014 (1)
  • September 2014 (2)
  • August 2014 (1)
  • July 2014 (2)
  • June 2014 (1)
  • April 2014 (1)
  • March 2014 (1)
  • February 2014 (2)
  • January 2014 (1)
  • December 2013 (1)
  • November 2013 (1)
  • October 2013 (3)
  • September 2013 (5)
  • July 2013 (1)
  • June 2013 (1)
  • May 2013 (1)
  • April 2013 (1)
  • March 2013 (2)
  • February 2013 (1)
  • January 2013 (2)
  • December 2012 (2)
  • October 2012 (1)
  • September 2012 (1)
  • July 2012 (1)
  • May 2012 (1)
  • April 2012 (1)
  • March 2012 (1)
  • February 2012 (1)
  • January 2012 (2)
  • December 2011 (1)
  • November 2011 (2)
  • October 2011 (2)
  • September 2011 (1)
  • July 2011 (1)
  • June 2011 (2)
  • April 2011 (1)
  • March 2011 (1)
  • February 2011 (1)
  • January 2011 (2)
  • November 2010 (2)
  • September 2010 (1)
  • August 2010 (1)
  • July 2010 (1)
  • June 2010 (1)
  • May 2010 (1)
  • April 2010 (1)
  • March 2010 (1)
  • February 2010 (1)
  • December 2009 (1)
  • November 2009 (1)
  • October 2009 (2)
  • September 2009 (2)
  • August 2009 (3)
  • July 2009 (1)
  • June 2009 (2)
Follow me on Twitter
Follow me on Linkedin
Follow me on Stackoverflow
Follow me on Rss
Link to my Contact
Follow me on Github
 
Fabian Piau | © 2009 - 2025
All Rights Reserved | Top ↑