JavaOne – 55 new features in Java 9

“55 new features in Java 9”

Speaker: Simon Ritter

For more blog posts from JavaOne, see the table of contents

  • Modularity/Jigsaw – JDK is 94 moudles. Java SE is 36 of them. Probably using sun.misc.Unsafe in open source library
  • Big kill switch now has options to permit/warn/debug (warn with stack trace)/deny(will be default at some point) illegal access
  • jlink – jaa linker so can build runtime specifically for your application. Creates directory structure for you that matches jdk but only wit the modules you need. java -list-modules shows what modules are in there. Version numbering information is for informational purposes only. Can’t use different versions for different parts of the code.
  • Static factory methods for List/Set/Map interfaces. Old way was to instantiate, add a bunch of elements and then call Collections.unmodifiableSet(). Now can just call Set.of(…) with 0-10 elements or varargs if have more and get an umodifiable collection
  • Stream enhancements – dropWHile/takeWhile (like skip/limit but with predicate rather than number), improved iterate to be more like a for loop, parallel Files.lines() as memory mapped and a stream from Optional with zero/one elements
  • multi-release jar files – use JDK 8 code in main jar file and then JDK 9 in the “9” diretory
  • jshell – REPL (read eval print loop) – good for simple prototyping
  • concurrency updates – reactive streams publish/subscribe framework, async nonblocking, Flow interfaces, SubmissionPublisher utility class.
  • CompleteableFuture additions (originally added in Java 8). Now has delays/timeouts, better support fr subclassing, static utility methods for minimalCompletionStage (read JavaDoc; confusing), failedStage, failedFuture [and one more]
  • Enhanced deprecation – forRemoval and since (not back ported consistently), jdeprscan command can produce report from jar or class file
  • Project Coin – single underscore not valid identifier (so in future can use _ in lambda instead of variable), priate method in interfaces, effectively final variables in tr-with-resources, allow @SafeVarars on private instance variables, diamond operate with anonyous classes
  • New standards – Unicode 7 (2834 new chars) and 8 (7716 new chars) support – added emojis, PKCS12 key stores by default, HTML 5 JavaDoc, etc
  • UTF-8 property files
  • DRBG based SecureRadom bit generators
  • XML catalog API upgraded standard
  • G1 is default garbage collector for servers (used to be parallel collectors), low pause, deals with bigger heaps
  • Better String performance – compact strings (use less space internally; don’t use 16 bits for chars that could be 8 bits), store interned strings in CDS archive to share char[] and String objects between VMs, String concatentaton to use invokedynamic (allows for future performance improvements at runtim)
  • Marlin graphics renderer – faster
  • A couple really low level VM performance things
  • JavaFX improvement
  • Segment Code cache – separates non-method, proiled and non-profiled code (enables future performance improvments)
  • Unified JVM and GC logging – using old options prevent JVM startup
  • Spin-wait hints. Small change to improve performance on x86, but Azul [where Simon works] proposed it showing openness of JEP.
  • Variable handles – API to replace parts of sun.misc.Unsafe. Used for fence operations (memory control/atomic operations preventing JVM from changing order of operations in code), VarHandle (low level objec)
  • AOT compilation – ahead of time compilation – experimental feature; need to turn on with UnlockExperimenalVMOptions. jaotc to comiple in this mode
  • Process API can get pid, arguments, start time, CPU usage and name if security manager allows
  • New version string format for java JDK major minor security patch. Will cange again post Java 10. No more 1.X
  • JDK/JRE file structure – only one bin directory no special jre direcory. tools.jar and rt.jar also went away.
  • Sarchable JavaDocs
  • Annotation pipeline – repeating annotations
  • Parser API for Nashorn – and spports ECMAScript 5.1
  • Disable SHA-1 certs mostly
  • Applets deprecated for removal in Java 10
  • A handful of APIs removed [not ommon ones]
  • Removed a few other things like hprof agent, jhat tool, old docs
  • Removed deprecated GC options

My take: He said up front that this talk is supposed to be an hour. Implying we won’t get to all 55 features. He didn’t sound rushed though so there wasn’t the problem from yesterday’s speaker with two much information. It was a good overview (or review) of the features. I learned some things like the eixstance of jdeprscan

Leave a Reply

Your email address will not be published.