33

A categorized list of all Java and JVM features since JDK 8

 3 years ago
source link: https://www.tuicool.com/articles/hit/EbiyEfn
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Since the release of version 8, up to version 11, Java is shaped by 120 JDK Enhancement Proposals (JEPs), each of which brings some improvement to the platform. I’ve decided to read them and create a concise, categorized list from the improvements.

RNnYBjI.png!web

Contents:

  • New Language Features
  • Performance Improvements
  • Security Improvements
  • Deprecation and Removal

Because there are many features in each category, I decided not to present them in chronological order, but start with those that seem most important. Also, I added the expected JDK 12 features to the end of each category.

New Language Features

When Java 8 introduced lambdas it was a pretty huge change. While recent versions did not add such impactful features, lots of smaller improvements were made to the language.

  • Introduction of var to make local variable declarations less ceremonious
    JDK 10 , JDK 11
    var greeting = "Hello World!";
  • Opt-in and backwards-compatible Module System to avoid ClassDefNotFoundErrors at runtime and create internal APIs
    JDK 9 (Project Jigsaw)
    module hu.advancedweb.helloworld {
        requires hu.advancedweb.somedependency;
        exports hu.advancedweb.hello
    }
  • Private methods in interfaces

    JDK 9 (Milling Project Coin)

  • Diamond operator for anonymous inner classes

    JDK 9 (Milling Project Coin)

  • Try-with-resources allows effectively final variables

    JDK 9 (Milling Project Coin)

  • @SafeVargs on private instance methods

    JDK 9 (Milling Project Coin)

  • No deprecation warnings on import statements

    JDK 9
  • Coming in JDK12: Switch Expressions (Preview)
    JEP 325
    int numLetters = switch (day) {
        case MONDAY, FRIDAY, SUNDAY -> 6;
        case TUESDAY                -> 7;
        case THURSDAY, SATURDAY     -> 8;
        case WEDNESDAY              -> 9;
    };

New APIs

Let’s continue with the Java Standard Library, focusing on the new features that we can use in day-to-day coding.

If you are curious about all the API level differences between Java 8 and 11, check the Java API diff between version 8 and 11 .

General

  • Convenience Factory Methods for Collections to ease the pain of not having collection literals
    JDK 9
    Set<Integer> mySet = Set.of(1, 2, 3);
    List<Integer> myList = List.of(1, 2, 3);
    Map<String, Integer> myMap = Map.of("one", 1, "two", 2);
  • Standard HTTP Client featuring HTTP/2, WebSocket support and non-blocking API
    JDK 9 (Incubator), JDK 11 (Standard)
    HttpClient httpClient = HttpClient.newBuilder().build();
    
    HttpRequest request = HttpRequest.newBuilder()
              .uri(URI.create("https://advancedweb.hu/"))
              .GET()
              .build();
    
    HttpResponse<String> response = httpClient.send(request, BodyHandlers.ofString());
  • Reactive Streams publish-subscribe framework for asynchronous stream processing with non-blocking backpressure

    JDK 9
  • Time-based enhancements to CompletableFuture (timeout, delay)

    JDK 9
  • String enhancements, like isBlank , lines , repeat and strip
    JDK 11

  • More options to transform ( dropWhile , takeWhile ) and generate ( iterate , ofNullable ) streams; readonly collectors ( toUnmodifiableList ); optionals can be transformed to streams

    JDK 9
  • Arrays.mismatch : find the first mismatching element between two arrays

    JDK 9
  • Stack-Walking API that allows laziness and stack-frame filtering

    JDK 9
  • Process API provides more info and control (e.g. process ID, arguments, CPU time, parent/child processes), enhance ProcessBuilder to aid the creation of process pipelines

    JDK 9
  • VarHandle API to replace the field and array related operations of java.util.concurrent.atomic and sun.misc.Unsafe in order to and provide low-level access mechamisms, e.g. atomic write.

    JDK 9
  • New combinators and lookup methods for MethodHandle
    JDK 9

  • Enhanced Deprecation policy. @Deprecated can be marked with forRemoval , which emits a new warning.

    JDK 9
  • OASIS Standard XML Catalog API to manage external resources in XMLs in a secure and performant manner

    JDK 9
  • Update JDK’s XML parser, Xerces, to version 2.11.0

    JDK 9
  • TIFF Support for Image I/O Framework

    JDK 9
  • Coming in JDK 12:String enhancements: align , indent and transform
    JDK 12

  • Coming in JDK 12: Files.mismatch : find the first mismatched byte in the content of two files

    JDK 12
  • Coming in JDK 12: Collectors.teeing to create a Collector that is a composite of two downstream collectors
    JDK 12

Internationalization

  • ResourceBundle loads properties files in UTF-8 instead of ISO-8859-1

    JDK 9
  • Unicode 10.0, adding roughly 27.000 characters, 10 blocks, and more than 30 scripts

    JDK 9 (Unicode 8.0), JDK 11 (Unicode 10.0)

  • java.util.Locale and related APIs support currency type, time zone and more

    JDK 10
  • CLDR Locale Data Enabled by Default

    JDK 9

Graphics and Desktop Applications

  • Desktop features for all platforms like login/logout/lock event listener and task bar interactions

    JDK 9
  • MultiResolutionImage that makes easy to retrieve a resolution-specific image for a DPI

    JDK 9
  • HiDPI Graphics on Windows and Linux

    JDK 9
  • Enable GTK 3 on Linux for JavaFX, Swing, and AWT

    JDK 9
  • Replace @beaninfo Javadoc tags with @BeanInfo annotations for Swing

    JDK 9
  • Update GStreamer included in JavaFX/Media to version 1.4.4

    JDK 9
  • Replace the existing ICU OpenType font-layout engine with HarfBuzz

    JDK 9

Performance Improvements

General

  • Space-efficient, Compact Strings that stores Latin-1 only Strings more efficiently

    JDK 9
  • Code caches of profiled and non-profiled compiled code is separated, resulting in improved performance and memory footprint

    JDK 9
  • Store Interned Strings in Class-Data Sharing archives to reduce memory consumption

    JDK 9
  • Application Class-Data Sharing to improve startup time and reduce footprint by sharing class metadata between Java processes.

    JDK 10
  • Coming in JDK 12:Class-Data Sharing archive of the default class list is enabled by default to improve out-of-the-box startup time

    JEP 341

Library related

  • Improved intrinsics for java.lang.Math sin , cos and log functions on AArch64 processors

    JDK 11
  • Security Manager performance improvements

    JDK 9
  • Spin-Wait Hint ( Thread#onSpinWait ) to optimize busy-waiting style loops

    JDK 9
  • Use Marlin Renderer in Java 2D as the default graphics rasterizer instead of Pisces

    JDK 9
  • Improved GHASH and RSA performance by leveraging recently-introduced SPARC and Intel x64 CPU instructions

    JDK 9

Concurrency

  • Improved performance of contended object monitors

    JDK 9
  • Extra space on thread stack for critical sections, mitigating the risk of a deadlock in java.util.concurrent locks in case of a stack overflow

    JDK 9
  • Thread-Local Handshakes to stop individual threads

    JDK 10

Compiler

  • Performance improvement in javac: new strategy for type checking poly expressions

    JDK 9
  • Experimental Ahead-of-Time Compilation capability for Linux

    JDK 9 (JVM Compiler Interface), JDK 9 (Graal as an AoT Compiler), JDK 10 (Graal as an experimental JIT Compiler)

Garbage Collectors

  • G1 Garbage Collector is now the default instead of Parallel GC

    JDK 9
  • G1 GC performance improvements: Parallel Full GC to improve worst-case latencies

    JDK 10
  • Introduce the Z Garbage Collector, which offers very low pause times on large heaps

    JDK 11
  • Introduce the Epsilon Garbage Collector, which does not implement actual memory reclamation, striving for the lowest overhead possible

    JDK 10 , JDK 11

  • XX:AllocateHeapAt=<path> to support Alternative Memory Devices

    JDK 10
  • Coming in JDK 12:G1 GC performance improvements: abortable mixed collections to meet user-supplied pause goals, automatically return Java heap memory to the operating system when idle

    JEP 344 , JEP 346

  • Coming in JDK 12:Introduce the Shenandoah Garbage Collector, offering similar benefits as ZGC but based on a different algorithm

    JEP 189

Diagnostic and Tools

  • Flight Recorder is part of OpenJDK

    JDK 11
  • Low-Overhead Heap Profiling via JMTI

    JDK 11
  • Run-time manageable and method specific control of the C1 and C2 compilers that enables contained tests

    JDK 9
  • Fine-grained, easy-to-configure Logging System for all components of the JVM

    JDK 9 (Unified JVM Logging), JDK 9 (Unified GC Logging)

  • Allow the application to provide logger implementation to be used by platform classes

    JDK 9
  • Coming in JDK 12:Microbenchmark Suite based on JMH

    JEP 230

Security Improvements

  • Validate Incoming Serialization Data

    JDK 9
  • Default keystore type is the standard PKCS12 instead of the proprietary JKS

    JDK 9
  • Default set of root Certification Authority (CA) certificates are provided with the JDK, so TLS connections are working out of the box

    JDK 10
  • DRBG-Based SecureRandom
    JDK 9

  • Disable X.509 certificate chains with SHA-1 based signatures

    JDK 9
  • SHA-3 Hash Algorithms

    JDK 9

TLS

  • TLS 1.3 support

    JDK 11
  • API for Datagram Transport Layer Security (DTLS)

    JDK 9
  • OCSP stapling TLS to improve performance of certificate status checking

    JDK 9
  • TLS Application-Layer Protocol Negotiation (ALPN) Extension which enables protocol negotiation without additional round trips; ALPN is a requirement for HTTP/2 connections

    JDK 9

Crypto

  • Key Agreement with Curve25519 and Curve448

    JDK 11
  • ChaCha20 and Poly1305 Cryptographic Algorithms

    JDK 11

Launching

  • jshell : the Java REPL

    JDK 9 (Project Kulla)

  • Launch Single-File Source-Code Programs, including support for shebang ( #! ) line on Unix

    JDK 11
  • Compile for Older Platform Versions with --release , which configures --source and --target and links against the appropriate platform version

    JDK 9
  • Early validatation of JVM Command-Line Flags to avoid crashes

    JDK 9

Packaging

  • jlink Java Linker that can build an optimized, slim run-time image for a modular Java application thag contains only the required parts of the JDK

    JDK 9 - [ 1 ], [ 2 ], [ 3 ], [ 4 ], [ 4 ], [ 5 ]

  • Multi-Release JAR Files to allow multiple, Java-release-specific versions of class in a single archive

    JDK 9

Javadoc

  • The Javadoc tool now emits HTML5 markup instead of a frame-based layout and the documentation contains a search box to ease navigation

    JDK 9 - [ 1 ], [ 2 ], [ 3 ]

Bytecode

  • Bytecode generated for static String-concatenation uses invokedynamic rather than directly creating StringBuilder#append chains. This will enable future optimizations of String concatenation without requiring bytecode changes.

    JDK 9
  • INVOKEDYNAMIC can express high-level operations on object properties and or collections

    JDK 9
  • CONSTANT_Dynamic constant-pool entry which uses bootstrapping to perform the resolution, similarly to INVOKEDYNAMIC calls

    JDK 11
  • Introduction of the Nest access-control context that wraps classes in the same code entity - such as nested classes - and eliminates the need for compiler to insert bridge methods to the generated bytecode.

    JDK 11
  • Coming in JDK 12: java.lang.invoke.constant package to allow easy description of loadable constants (operands for the ldc instruction), which is less error-prone than relying on ad-hoc String representation

    JEP 334

New platforms

JDK 9 brings support for three additional platforms:

Deprecation and removal

This section summarizes the breaking changes and deprecations between Java 8 and 11.

  • Underscore is no longer a valid identifier ( JDK 9 )
  • var is no longer a valid class name ( JDK 10 )
  • Remove Java EE ( JDK 11 )
  • Remove CORBA ( JDK 11 )
  • Internal API’s ( sun.* ) are removed or deprecated (JDK 9 - [ 1 ], [ 2 ])
  • Remove apple.applescript and com.apple packages ( JDK 9 )
  • Disable X.509 certificate chains with SHA-1 based signatures ( JDK 9 )
  • Remove Launch-Time JRE Version Selection directives: JRE-Version manifest entry and -version: cli option ( JDK 9 )
  • Remove the jhat tool ( JDK 9 )
  • Remove the JVM TI hprof Agent ( JDK 9 )
  • Remove GC Combinations Deprecated in JDK 8 ( JDK 9 )
  • Remove the javah tool ( JDK 10 )
  • Remove Thread#destroy and Thread#stop .
  • Remove the Endorsed Standards Override ( lib/endorsed ) and Extensions ( lib/ext ) mechanisms from the JRE.
  • Remove rt.jar from the JRE.
  • ResourceBundle loads properties files in UTF-8 instead of ISO-8859-1 ( JDK 9 )
  • Deprecate Applet API ( JDK 9 )
  • Deprecate Nashorn Javascript Engine ( JDK 11 )
  • Deprecate the Concurrent Mark Sweep Garbage Collector ( JDK 9 )
  • Deprecate Object.finalize() ( JDK 9 )
  • Deprecate the Pack200 Tools and API ( JDK 11 )

If you are curious about all the API level differences between Java 8 and 11, check the Java Almanac project. Also check out jdeps , the Java class dependency analyzer to find out if your project is still using an old internal API.

New Version Scheme

  • Simpler Version-String Scheme, aligned with Semantic Versioning.

    JDK 9 , JDK 10

Summary

JDK 8 was released in 2014. We had to wait for three and a half years for JDK 9 . But since then things accelerated. Java has a new release structure that aims to deliver a new version in every six months. JDK 10 and JDK 11 already came out with many features.

While Java 8 is still supported, migrating to Java 11 brings considerable amount of improvements to the table.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK