Tuesday, April 30, 2019

Java Streams

Null elements in the stream

I thought, I saw a statement that Java streams filters out the null elements in the stream but the information must have been wrong.  So, if nulls are expected, or just in case, do:

... .filter(Objects::nonNull). ....

Monday, April 29, 2019

Java 9 - What's New In It


Modules

  • defined by file module-info.java in the module root directory
  • defines the module name, which package the module exports and
    what other modules it requires
  • if package org.sjb exports to a module, its subpackage isn't
    exported automatically; it can be exported by any module
  • each package is exported by a single module
  • jlink - packages a modules with all its required modules and the needed parts of the JRE into a standalone app which won't need Java to be installed where it runs
  • unnamed modules - all not defined stuff gets packed into a single unnamed module.  It exports all packages but only unnamed modules can call them.
  • automatic modules ...

Services


Using modules, the client code can receive all available implementations
  of an interface, and choose as one it needs (server and client are in the same JVM;
  it's not about http clients)