About Johannes Thones

Johannes is a Software-Developer, ThoughtWorker, Permanent Journeyman, Ruby Enthusiast, Java and Devils Advocate. He lives and works in Hamburg, Germany.

Java 8 Status Updates

The two big new language features of the upcoming Java SE 8 release are Lambda Expressions and Modularity. For both, status updates have been released these days. I’ll share the links with you, so you might read through them over the holidays ;-)
The Java SE 8 release is planned for mid 2013 by Oracle.

Project Lambda

Project Lambda as well as the JSR-335 wants to provide means for modelling of code as data in Java – in non-exact, colloquial words one could say it aims for functions as first-class objects in Java. To do so, Project lambda wants to provide the following four extensions to the Java language:

  1. Lambda Expressions or Closures which allow the programmer to specify a piece of executable code in an idomatic way. They can be stored in a variable, passed to a method as argument or used as return value of a method.
  2. Expandend Target Typing to bind the Lambda Expressions to objects of a specific type (type inference). These types can be so-called Function Interfaces – Java interfaces with exactly one method.
  3. Method and Constructor References to allow the programmer to use existing methods on objects to be bound to a a Function Interface.
  4. Default or Virtual Extension Methods to add more methods to existing interfaces without breaking existing implementations (especially in the collection library).
To give you an idea, here is a piece of code using anonymous inner-classes for some collection logic.
List students = // ...
students.filter(new FilerFunction(){
    @Override
    public boolean filter(Student s){
      return s.getEntryYear() == 2011;
    }
    })
  .map(new MapFunction<Student,Integer>(){
    @Override
    public Integer map(Student s){
      return s.getGrade();
    }
  })
  .reduce(new ReduceFunction<Integer>(){
    @Override
    public Integer reduce(Integer value1, Integer value2){
      Math.max(value1, value2);
    }
  });

In contrast the following code using the features on their way with Project Lambda:

List students = // ...
students.paralell()
  .filter(s -> s.getEntryYear() == 2011)
  .map(s -> s.getGrade())
  .reduce(Math::max);

The information about the current state from Specification Lead and OpenJDK Project Lead Brian Goetz can be found at State of the Lambda.

Project Jigsaw – Modularity for the Java Platform

In Project Jigsaw, the OpenJDK community lead by Oracle tries to introduce modularity into Java the language. The approach will be different from e.g. OSGi, because they want to establish it on the language level – with static compile time checking. The Oracle people always say they strive for compatibility of Jigsaw with OSGi.
Marc Reinhold, Oracles Chief Platform Architect and OpenJDK Project Lead, describes three principles of the modularity approach:

  • Modularity is a language construct – The best way to support modular programming in a standard way in the Java platform is to extend the language itself to support modules. Developers already think about standard kinds of program components such as classes and interfaces in terms of the language; modules should be just another kind of program component.
  • Module boundaries should be strongly enforced – A class that is private to a module should be private in exactly the same way that a private field is private to a class. In other words, module boundaries should determine not just the visibility of classes and interfaces but also their accessibility. Without this guarantee it is impossible to construct modular systems capable of running untrusted code securely.
  • Static, single-version module resolution is usually sufficient – Most applications do not need to add or remove modules dynamically at run time, nor do they need to use multiple versions of the same module simultaneously. The module system should be optimized for common scenarios but also support narrowly-scoped forms of dynamic multi-version resolution motivated by actual use cases such as, e.g., application servers, IDEs, and test harnesses.

For the programmer using Jigsaw, it will be especially noticable because the language will now have three phases (instead of two):

  • Compile Time: The classes of a module are compiled. The compiled classes together with the resources (configuration files, metadata files etc.) are packed together in an archive in the format of JMOD (for java module):
  • Install Time: On any computer having the JRE installed, there will be a module library. Here the user can install java modules.
  • Run Time: A module defining a main class (Invokable Module) can be executed. The JVM will load this module and any module it requires from the module library and then execute the code.

Information about the the current state of Project Jigsaw from Marc Reinhold can be found at Project Jigsaw: The Big Picture — DRAFT 1.

Reference: Java 8 Status Updates from our JCG partner Johannes Thönes  at the Johannes Thönes blog.

Related Articles :

Do you want to know how to develop your skillset to become a Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you two of our best selling eBooks for FREE!

JPA Mini Book

Learn how to leverage the power of JPA in order to create robust and flexible Java applications. With this Mini Book, you will get introduced to JPA and smoothly transition to more advanced concepts.

JVM Troubleshooting Guide

The Java virtual machine is really the foundation of any Java EE platform. Learn how to master it with this advanced guide!

Given email address is already subscribed, thank you!
Oops. Something went wrong. Please try again later.
Please provide a valid email address.
Thank you, your sign-up request was successful! Please check your e-mail inbox.
Please complete the CAPTCHA.
Please fill in the required fields.

Leave a Reply


× 9 = thirty six



Java Code Geeks and all content copyright © 2010-2014, Exelixis Media Ltd | Terms of Use | Privacy Policy | Contact
All trademarks and registered trademarks appearing on Java Code Geeks are the property of their respective owners.
Java is a trademark or registered trademark of Oracle Corporation in the United States and other countries.
Java Code Geeks is not connected to Oracle Corporation and is not sponsored by Oracle Corporation.
Do you want to know how to develop your skillset and become a ...
Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you two of our best selling eBooks for FREE!

Get ready to Rock!
You can download the complementary eBooks using the links below:
Close