logo

What's new in Java 11 (Changes in JDK 9, 10, 11)

Java changed release schedules, though the version number bumps up every 6 months, Java 11 is the first long term supported version after Java 8, and the next likely LTS version is Java 17. This page lists changes in JDK 9 through 11.

Language and Library Changes

Changes in how we code:

  • Modules
  • JEP 286 / JEP 323 Local-variable: var foo = new Foo();, (var x, var y) -> x.process(y)(equivalent to (x, y) -> x.process(y))
  • private methods in interfaces.
  • JEP 321/JEP 110 HTTP Client API: java.net.http
  • Updated to Unicode 10
  • JEP 102 Improvements to java.lang.Process and java.lang.ProcessHandle

And "JRE" is no longer a thing after JDK 9.

Easier Ways to Learn Java

jshell

JEP 222

An interactive shell for java.

Single-File Source-Code Programs

JEP 330

Execute a single .java file like other scripting languages(e.g. Python).

Add shebang to the beginning of the file.

#!/path/to/java --source version

This command:

$ java HelloWorld.java

is informally equivalent to

javac -d <memory> HelloWorld.java
java -cp <memory> hello.World

Under the Hood

  • JDK 9: jlink tool to create customized runtime. (1) The java.base module must be included in the runtime; (2) if any other Java SE Spec defined modules are included, all the dependencies(requires elements in module-info.java file) must be included.
  • JDK 11: removed Applets and Java Web Start.
  • default garbage collector changed from CMS to G1
  • JEP 254 Compact Strings: change internal String representation from UTF-16(2 bytes per character) to byte array, depending on character type, latin character may only take 1 byte. This is different than the one with UTF-8 as encoding.
  • JEP 280 The bytecode for string concat changed to use invokedynamic. In Java 8, invokedynamic was only used for lambdas.
  • JEP 309 CONSTANT_Dynamic: a new constant-pool form.
  • CDS(Class Data Sharing): Share classes/data between multiple JVMs by using shared memory: loaded classes, Ahead-Of-Time (AOT) compiled code, commonly used UTF-8 strings, and Java Archive (JAR) file indexes. Available in commercial JVMs(e.g. from IBM and Oracle) as early as Java 5; became open-source since JDK 10. CDS helps reduce the startup time and memory footprint. -Xshare:auto is enabled by default for the server VM in JDK 11.

Tech Debt

  • JEP 214 Remove Deprecated GC Combinations
  • JEP 231 Remove Launch-Time JRE Version Selection
  • JEP 240 Remove hprof: stop building and shipping the hprof agent library (libhprof.so) as part of the JDK.
  • JEP 241 Remove jhat
  • JEP 298 Remove Demos(jdk/src/demo) and Samples(jdk/src/sample)
  • JEP 313 Remove javah, superseded by javac
  • JEP 320 Remove Java EE and CORBA Modules
  • JEP 335 Deprecate Nashorn and jjs
  • JEP 336 Deprecate the pack200 and unpack200 tools, and the Pack200 API in java.util.jar.Pack200. The compression tool is deprecated because download speed improved and modules were introduced in JDK 9.
  • JEP 289 Deprecate Applet API java.applet
  • JEP 291 Deprecate CMS
  • JEP 296 Consolidate the JDK Forest into a Single Repository
  • JEP 299 Reorganize Documentation