Core Library Improvements in Java 9 BASH

Core Library Improvements in Java 9 reportage with Richard Warburton and Raoul Gabriel Urma

Richard Warbuton + Raoul Gabriel-Urma Pizza After

On Monday 26th of February, fifty or so hardy souls braved the bad weather to hear Richard Warburton and Raoul-Gabriel-Urma present on 'Core Library Improvements in Java 9'.

Richard and Raoul have an international reputation which gathered a great crowd for a Monday, although the free pizza and beer may also have been a factor :-)

Pizza Before Pizza After

The presenters made two bold choices. First to live code the entire presentation and second to present in the form of a Socratic dialogue, whereby one presenter asks simple questions of the other and is gradually led along the path to wisdom. This is a tough act to pull off live, but they managed well and it made for an entertaining change of pace.

All coding was done through the new JShell REPL, which allows fragments of Java code to be evaluated on the fly. The topics covered included:

  • Simplified creation of collections with items
  • Additional methods on streams and collections
  • Extensions to the 'Optional' type

Of particular interest to me was the ability to integrate filters and flat-mapping into the standard collect method. For example the following code builds a table where the keys are the names of countries where a company employs staff and the values are lists of employees. The new flatMapping operator prevents the lists containing a nested list for each department.

staffByCountry = offices.stream()
    .collect(groupingBy(Office::getCountry,
             flatMapping(office -> office.getStaff().stream(),
             toList())));

After the presentation there were a number of questions about backward compatibility in Java 9 and the new features arriving in versions 10 and 11. The new Java Module System was also mentioned, but this was too involved for the time remaining and so was rain checked until another event. The evening finished with a number of well deserved rounds of applause for the presenters and the announcement that the next BASH will be devoted to Machine Learning, hopefully to be scheduled for mid April.