What's new in Java 11 (Changes in JDK 9, 10, 11)
Last Updated: 2021-11-19
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:
- 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:
- Updated to Unicode 10
- JEP 102 Improvements to
And "JRE" is no longer a thing after JDK 9.
Easier Ways to Learn Java
An interactive shell for java.
Single-File Source-Code Programs
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
$ java HelloWorld.java
is informally equivalent to
javac -d <memory> HelloWorld.java java -cp <memory> hello.World
Under the Hood
- JDK 9:
jlinktool to create customized runtime. (1) The
java.basemodule must be included in the runtime; (2) if any other Java SE Spec defined modules are included, all the dependencies(
module-info.javafile) 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,
invokedynamicwas 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:autois enabled by default for the server VM in JDK 11.
- JEP 214 Remove Deprecated GC Combinations
- JEP 231 Remove Launch-Time JRE Version Selection
- JEP 240 Remove
hprof: stop building and shipping the
hprofagent library (
libhprof.so) as part of the JDK.
- JEP 241 Remove
- JEP 298 Remove Demos(
jdk/src/demo) and Samples(
- JEP 313 Remove
javah, superseded by
- JEP 320 Remove Java EE and CORBA Modules
- JEP 335 Deprecate Nashorn and
- JEP 336 Deprecate the
unpack200tools, 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
- JEP 291 Deprecate CMS
- JEP 296 Consolidate the JDK Forest into a Single Repository
- JEP 299 Reorganize Documentation