Le blog de Fabien DUMINY

Un blog utilisant WordPress

Skip to: Content | Sidebar | Footer

Paris JUG – Java.next()

23 March, 2012 (10:00) | Event, Java, Paris JUG | By: fabien

Thursday 13th March 2012, I attended to the Java.next() evening at the Paris JUG to see the presentations of Jigsaw and Lambda projects.

Alexis Moussine-Pouchkine starts his presentation of the Jigsaw project by a quick talk about small things introduced by Java 7. He notably speaks about the Coin project, which introduce small modifications and utilitary functions in the JDK. Among these ones, one can find a new class named Objects that provides static methods like equals(Object, Object), hashCode(Object), toString(Object) and deepEquals(Object, Object) that manage case where one of the parameters is null. These ones already existed in the ObjectUtils class from the apache commons lang library but it’s better to have that in the JDK.
Next, Alexis speaks about the subject which is the Jigsaw project. The JDK is monolithic and becomes bigger as new versions are coming. This project will make it more modular. All developers using Java 8 will be impacted by this project. Thus, there won’t have a classpath anymore, at compilation time or at runtime. A jar file will become a module (jmod file). The module-info class located at the root of the module allow to define its characteristics :

  • Module’s name and its version
  • Optional name of the main class (same concept as jar files)
  • Prerequisite modules, defined by their name and their version
  • Packages to hide (that allows to hide some public classes)
  • …etc…

This project also introduce the concept of library which is a set of modules. To begin, only one library will be created : the JDK library. Each library has a parent, which is by default the JDK.
Another new concept is the repository, which is a remote server containing libraries.

Making the JDK more modular is not an easy task. Thus, to make a simple Hello world, dependencies problems force to have the corba package in the classpath !
The simplification of dependencies has already started in the JDK 7.

A compatibility mode can be activated to avoid recompilation of all existing java libraries. Without that, JDK 8 would take the risk to be adopted less quickly ;-)

Remarks :

  • In the Jigsaw project there is a prototype using the Maven central repository as a repository for libraries (in the form of jar files). The issue is that dependencies are not always good.
  • The Penrose project has been created in order to study and provide an interoperability in the 2 directions between the Jigsaw project and OSGI

For the second part of the evening, Rémi Forax show us the Lambda project. Before speaking about the suject itself, Rémi, as conference master for the Paris-Est Marne-la-Vallée university, attract our attention to the need of apprentice jobs for its students (see the page apprenticeship training of the university). Then he starts speaking about Lambdas. A Lambda is an anonymous function, which could be translated in java by a Single Abstract Method (SAM), an interface with a single method : it’s the case for Callable and Runnable interfaces. But it’s not enought to define a Lambda because it’s also an anonymous function able to, for example, represent all methods taking 2 integers and returning an integer. It’s not possible to represent that now in java without naming the method.

According to Rémi, Lambdas will essentially be useful for interfaces from the java.util package (by adding for example the sort method to the List interface) but how to add a method in these ones without breaking the compatibility in all existing java code ? The proposed solution introduce the ability to define a default implementation for each interface’s method. Simple rules for multiple inheritance must be defined to make it work.

For better performances, this solution will be implemented by proxies at runtime because the JVM will be able to optimize all that (no new class, less work for the verifier; optimisation if the method is never called …), which wouldn’t be the case for an implementation in the compiler. For now, the implementation is slower but Rémi hope to solve this problem.

Developments should be merged with the JDK 8 in april, but probably not before Devoxx France 2012.

Be Sociable, Share!
Share and Enjoy

Write a comment





If your website is claim enabled, it will be notified that you have posted here.

MySQL query error