Highlights of the latest GA release of standard Java include flight recorder event streaming, switch expressions, NVM support, and records Credit: Gregory Hayes Java Development Kit (JDK) 14 has reached GA, arriving in a general-availability release for production deployments. The upgrade to standard Java includes new capabilities such as JDK Flight Recorder event streaming, pattern matching, and switch expressions. JDK 14 is a feature release of Java, rather than a long-term support (LTS) release, following the six-month release cadence set for Java. JDK 14 will receive security updates in April and July before being superseded by JDK 15, also a non-LTS release, which is due in September. The current LTS release is JDK 11. The new features and improvements in JDK 14 include: JFR Event Streaming provides an API for the continuous consumption of JFR data from both in-process and out-of-process applications. JFR is a tool for collecting profiling and diagnostic data about a Java application and the JVM as they’re running. The event streaming proposal records the same set of events as for the non-streaming case, with overhead of less than one percent if possible. Event streaming must co-exist with non-streaming recordings, both disk-based and memory-based. Motivating this proposal is a situation in which the HotSpot VM emits more than 500 data points using JFR, most of them available only by parsing log files. Currently, a user must start a recording, stop it, dump the contents to disk, and then parse the recording file. This works well for application profiling, but not for monitoring purposes. An example of monitoring usage is a dashboard that displays dynamic updates to data. There is overhead with creating a recording, such as copying data from the disk repository to a separate recording file. If there were a way to read data being recorded from the disk repository without creating a new recording file, much of the overhead could be avoided. The planned improvement to NullPointerExceptions pertains to improving the usability of the exceptions generated by the JVM by describing exactly which variable was null. Authors of the proposal are looking to provide helpful information to developers and support staff about the premature termination of a program and improve program understanding by more clearly associating a dynamic exception with static program code. One goal is to reduce confusion and concern developers have about NullPointerExceptions. Non-volatile mapped byte buffers would add new JDK-specific file mapping modes that allow the FileChannel API to be used to create MappedByteBuffer instances that refer to non-volatile memory (NVM). NVM enables programmers to build and update program state across program runs without incurring the significant copying or translation costs that input and output operations usually require. This is particularly significant for transactional programs. Thus the chief goal of this JDK Enhancement Proposal is to ensure that clients can access and update NVM from a Java program coherently and efficiently. A secondary goal is to implement this commit behavior using a restricted, JDK-internal API defined in class Unsafe, so it can be re-used by classes other than MappedByteBuffer that may need to commit to NVM. Another goal is to allow buffers mapped over NVM to be tracked by existing APIs for monitoring and management. Target OS/CPU platforms include Linux/x64 and Linux/AArch64. Switch expressions simplify coding by extending switch so that it can be used as either a statement or an expression. Switch expressions are expected to be a permanent feature in JDK 14, after being previewed in both JDK 12 and JDK 13. Switch expressions also prepare for the use of pattern matching in switch. Pattern matching allows developers to conditionally extract components from objects more concisely and safely. NUMA-aware memory allocation for the G1 garbage collector, intended to improve G1 performance on large machines. Removal of the Concurrent Mark Sweep (CMS) garbage collector, which previously was deprecated and slated for removal. Successors to CMS have arisen including ZGC and Shenandoah. Porting of ZGC to MacOS. It has been supported only on Linux thus far. Removal of the pack200 and unpack200 tools and the Pack200 API in the java.util.jar package. These all were deprecated in Java SE 11 with the intent to remove them in the future. Pack200 is a compression scheme for JAR files. Records, which would provide a compact syntax for declaring classes that are transparent holders for shallowly immutable data. Records make it easy to create classes that are essentially data carriers without having to write a lot of boilerplate. The proposal states it should be easy and concise to declare shallowly immutable, well-behaved, nominal data aggregates. A packaging tool, in an incubator phase of development, for packaging self-contained Java applications. The tool would be based on the JavaFX javapackager. Such a tool had been included in Java but was cut from JDK 11 as part of the removal of JavaFX. Enhance the language with pattern matching for the instanceof operator. This would be a preview feature in JDK 14. Pattern matching allows common logic in a program, principally the conditional extraction of components from objects, to be more concisely and safely expressed. Code can be made brief and type-safe. A second preview of text blocks, a multi-line string literal that avoids the need for most escape sequences and automatically formats the string in a predictable way. Text blocks would give the developer control over the format when desired, simplify the writing of Java programs, and enhance the readability of strings. Text blocks was previewed in JDK 13; the JDK 14 iteration would add escape sequences for managing explicit white spaces and newline control. Deprecating the combination of the Parallel Scavenge and Serial Old garbage collection algorithms. Java maintainers believe this combination is used very little but requires a lot of maintenance. Porting of the ZGC (Z Garbage Collector) to Windows. This feature has once again moved to the officially targeted list, after having been reverted back to the proposed-for-targeting list. Foreign-memory access API, with the introduction of an API for Java programs to safely and efficiently access foreign memory outside of the Java heap. This API should serve as an alternative to the main avenues by which Java programs access memory, including nio.ByteBuffer and sun.misc.Unsafe. The new API should be able to operate on various kinds of memory including native, persistent memory, and managed heap. It should not be possible for the API to undermine the safety of the JVM. Memory deallocation should be explicit in the source code. The API is expected to aid in the development of the native interoperation support that is the goal of Project Panama. Deprecation of the Solaris/Sparc, Solaris/x64, and Linux/Sparc ports, with the intent to remove them in a future release. Dropping support for these ports will enable OpenJDK contributors to accelerate the development of new features. Although Solaris and Sparc were linchpin technologies at Sun Microsystems, the original creator of Java, they have been superseded in the technology space in recent years by the Linux OS and Intel processors. Where to download JDK 14 You can download open source JDK 14 from jdk.java.net for Linux, Windows, and macOS. You can download Oracle commercial Java SE 14 downloads from Oracle.com. Related content feature 14 great preprocessors for developers who love to code Sometimes it seems like the rules of programming are designed to make coding a chore. Here are 14 ways preprocessors can help make software development fun again. By Peter Wayner Nov 18, 2024 10 mins Development Tools Software Development feature Designing the APIs that accidentally power businesses Well-designed APIs, even those often-neglected internal APIs, make developers more productive and businesses more agile. By Jean Yang Nov 18, 2024 6 mins APIs Software Development news Spin 3.0 supports polyglot development using Wasm components Fermyon’s open source framework for building server-side WebAssembly apps allows developers to compose apps from components created with different languages. By Paul Krill Nov 18, 2024 2 mins Microservices Serverless Computing Development Libraries and Frameworks news Go language evolving for future hardware, AI workloads The Go team is working to adapt Go to large multicore systems, the latest hardware instructions, and the needs of developers of large-scale AI systems. By Paul Krill Nov 15, 2024 3 mins Google Go Generative AI Programming Languages Resources Videos