Java 9-14 Improvements Compilation

This is an attempt to summarize most notable changes in Java 9-14 on a single page.

Java 9

Features:

  • Jigsaw
  • Process management with java.lang.ProcessHandle (parent/children relationship, process supervision etc)
  • Try with resources: may use a resource declared outside of try (...) {...} block
  • Diamond <> operator for anonymous inner classes
  • Interface private methods to split lengthy default methods
  • JShell command line tool
  • JCMD sub-commands: see all VM.flags subcommands with jcmd [pid] VM.flags -all
  • Multi resolution image API with java.awt.image.MultiResolutionImage
  • java.lang.invoke.VarHandle and java.lang.invoke.MethodHandle to replace sun.misc.Unsafe functionality
  • Reactive streams publish-subscribe with java.util.concurrent.Flow
  • Unified logging with java -Xlog parameter

New API:

  • java.util.Set.of()
  • java.util.Optional.stream() to convert an Optional into a Stream
  • Runtime.version()

Minor/performance:

  • String concatenation with + is faster, but code must be recompiled with Java >=9
  • HashMap.computeIfAbsent() may throw ConcurrentModificationException if incorrectly used in Java 8
  • Collection.removeIf() is faster
  • HashSet.removeIf() is faster
  • Class.getConstructor() is faster, less memory hungry
  • Class.reflectionData - reflection memory savings if reflection is not used
  • String.join() is faster
  • String.replace() is faster
  • Arrays.asList().iterator() is faster
  • Properties.getProperty() is faster
  • Collections .hashCode() improvements (shortcuts)
  • Math.hypot() is much faster

Java 10

Features:

  • Runtime.version() to use new JDK time based versioning $FEATURE.$INTERIM.$UPDATE.$PATCH
  • Local variable type inference var abc = "Hello, World!"
  • Java based JIT compiler, to compile Java with Java: enable with java -XX:+UnlockExperimentalVMOptions -XX:+UseJVMCICompiler
  • Application Class Data Sharing: java -XX:+UseAppCDS
  • Parallel Full GC for G1 - JEP 307
  • GC Interface for custom GC implementations - JEP 304
  • Additional Unicode Language-Tag Extensions - JEP 314
  • Root CA’s uplift
  • Thread Local Handshakes - performance improvement, see JEP 312
  • Heap allocation on alternative devices, see JEP 316
  • javah removed, use javac -h instead
  • policytool removed, use text editor instead
  • java -Xprofoption removed, use jmap instead
  • Single JDK source code repository
  • Container awareness java -XX:-UseContainerSupport: set processor count and min/max/start memory

New API:

  • APIs removed: 2 in java.lang.Runtime, 7 in java.lang.SecurityManager, 1 in java.lang.Character
  • 73 new APIs added
  • List, Map & Set Interfaces are added with a static copyOf(Collection)
  • Optional & its primitive variations get a method orElseThrow()
  • Collectors class gets various methods for collecting to unmodifiable collections (Set, List, Map)

Java 11

Features:

  • Run Java file with single command java MyCommand.java
  • java.net.http HttpClient - pretty decent Http client implementation
  • Local-Variable Syntax for Lambda Parameters (var a, var b) -> a + b
  • Nested Based Access Control for nested classes trying to use parent classes private methods via Reflection API
  • Dynamic Class-File Constants - JEP 309 (Performance)
  • Epsilon: A No-Op Garbage Collector
  • Remove the Java EE and CORBA Modules: java.xml.ws, java.xml.bind, java.activation, java.xml.ws.annotation, java.corba, java.transaction, java.se.ee, jdk.xml.ws, jdk.xml.bind
  • Flight Recorder
  • ChaCha20 and Poly1305 Cryptographic Algorithms
  • Deprecate the Nashorn JavaScript Engine
  • Deprecate Pack200
  • TLS 1.3
  • Unicode 10

New API:

  • String.repeat() - repeats same string n times
  • String.isBlank() and String.lines()
  • String.strip() - Unicode-aware String.trim()
  • Files.readString() / Files.writeString()
  • List.toArray(IntFunction<T[]> generator) To specify array size
  • Predicate.not() for streams: Stream.of(..).map(Predicate.not(String::isBlank))...

Minor/performance:

  • Class.class.getCanonicalName() / getSimpleName() is as fast as getName()

Java 12

Java 13

Minor/performance:

  • String.hashCode() is faster for zero-hash Strings
  • String.concat() is faster because it is using uninitialized arrays
  • String.replace() is faster than Java 9
  • Collections.nCopies().hashCode() is faster
  • Math.abs() is 2x times faster

Java 14

Minor/performance:

  • HashSet.toArray() is faster

Java 15

Minor/performance:

  • TreeMap.putIfAbsent() / computeIfAbsent() / computeIfPresent() / compute() / merge() is faster
  • TreeMap.computeIfAbsent() may throw ConcurrentModificationException
  • HashMap.containsKey() is faster especially for an empty map

Java 16

Minor/performance:

  • String + Empty string is faster
Published:
comments powered by Disqus