Still hot off the press, JDK-20 is out! These are terrific news, but what about exciting new features? Although a number of JEPs made it into the release, all of them are either preview or incubation features:
JEP-429: Scoped Values (Incubator): introduces scoped values, which enable the sharing of immutable data within and across threads. They are preferred to thread-local variables, especially when using large numbers of virtual threads.
JEP-432: Record Patterns (Second Preview): enhances the Java programming language with record patterns to deconstruct record values. Record patterns and type patterns can be nested to enable a powerful, declarative, and composable form of data navigation and processing.
JEP-433: Pattern Matching for switch (Fourth Preview): enhances the Java programming language with pattern matching for switch expressions and statements. Extending pattern matching to switch allows an expression to be tested against a number of patterns, each with a specific action, so that complex data-oriented queries can be expressed concisely and safely.
If you keen to learn more, please check out Using Pattern Matching publication, a pretty comprehensive overview of this feature.
JEP-434: Foreign Function & Memory API (Second Preview): introduces an API by which Java programs can interoperate with code and data outside of the Java runtime. By efficiently invoking foreign functions (i.e., code outside the JVM), and by safely accessing foreign memory (i.e., memory not managed by the JVM), the API enables Java programs to call native libraries and process native data without the brittleness and danger of JNI.
JEP-436: Virtual Threads (Second Preview): introduces virtual threads to the Java Platform. Virtual threads are lightweight threads that dramatically reduce the effort of writing, maintaining, and observing high-throughput concurrent applications.
JEP-437: Structured Concurrency (Second Incubator): simplifies multithreaded programming by introducing an API for structured concurrency. Structured concurrency treats multiple tasks running in different threads as a single unit of work, thereby streamlining error handling and cancellation, improving reliability, and enhancing observability.
JEP-438: Vector API (Fifth Incubator): introduces an API to express vector computations that reliably compile at runtime to optimal vector instructions on supported CPU architectures, thus achieving performance superior to equivalent scalar computations.
The pessimists may say this is the most boring release of JDK yet, but the optimist would argue that this is the calm before the storm (yes, I am talking about the next LTS release later this year, JDK-21). Nonetheless, there are quite a few notable changes to look at.
JDK-8283093: JMX connections should default to using an ObjectInputFilter: enables RMI object filtering for JMX by default, by giving a default value to the existing
management.properties
setting,com.sun.management.jmxremote.serial.filter.pattern
. The intent is to limit possible misuse of a JMX connection.The ability to stop, suspend, or resume a thread with the corresponding
Thread.stop()
,Thread.suspend()
orThread.resume()
methods have been eliminated. Those methods have been degraded to throw ajava.lang.UnsupportedOperationException
exception as per JDK-8249627: Degrade Thread.suspend and Thread.resume and JDK-8289610: Degrade Thread.stop.JDK-8293590: Some syntax checks performed by URL.openConnection() could be performed earlier, at URL construction: previously, some of the parsing and validation actions performed by the
URLStreamHander
implementations were delayed untilURLStreamHandler::openConnection
orURLConnection::connect
calls. Starting from JDK-20, some of these checks are performed earlier, at construction time, whenURLStreamHandler::parseURL
is called. A new JDK system propertyjdk.net.url.delayParsing
can be specified on the command line to revert to the previous behavior.JDK-8297609: Add application/wasm MIME type for wasm file extension: adds
application/wasm
as a MIME type for WebAssembly mapping in the default shipped with the JDKcontent-types.properties
file (for the reference, please check https://www.iana.org/assignments/media-types/application/wasm).JDK-8295803: Console should be usable in jshell and other environments
JDK-8301863: ObjectInputFilter example incorrectly calls rejectUndecidedClass
JDK-8254711: Add java.security.Provider.getService JFR Event: adds an event each time a JCE cryptographic service for a specific algorithm is requested and/or used.
JDK-8291753: Add JFR event for GC CPU Time and JDK-8292373: Add JFR event for GC CPU Time (other GCs): adds a JFR event which includes same information through GCTraceCPUTime.
The standard library was the one benefited the most in JDK-20 release, let us take a closer look at what has changed:
-
The java.io.BufferedInputStream got a specialized implementation for long transferTo(OutputStream out) throws IOException
-
The java.io.PushbackInputStream got a specialized implementation for long transferTo(OutputStream out) throws IOException
-
The java.io.SequenceInputStream got a specialized implementation for long transferTo(OutputStream out) throws IOException
The java.lang.Float got two new conversion methods:
The java.lang.reflect package was enhanced with:
The java.lang.reflect.Field got a new method:
The java.lang.reflect.Member got a new method:
The java.lang.reflect.Parameter got a new method:
The java.lang.Class class got a new method as well:
A new method was added to java.lang.module.ModuleDescriptor class:
The java.net.URL was enhanced with a factory method:
A new methods found their way into java.nio.file.spi.FileSystemProvider:
As part of JDK-8297648: j.u.concurrent updates for JDK 20, couple of classes where enriched with new methods:
The java.util.concurrent.ForkJoinPool has gotten:
The java.util.concurrent.ForkJoinWorkerThread has gotten:
A long standing bug JDK-8178355: IdentityHashMap uses identity-based comparison for values everywhere except remove(K,V) and replace(K,V,V) Export has been finally fixed by providing overrides in java.util.IdentityHashMap for:
A couple of changes touched javax.net.ssl.SSLParameters class:
The improvements made inside java.util.regex package came as a pleasant surprise, those are related to named groups (JDK-8292872: MatchResult should provide values of named-capturing groups):
The java.util.regex.Matcher class got new methods:
The interface java.util.regex.MatchResult also got new methods:
The java.util.zip.ZipInputStream introduces overrides for methods:
A couple of new public constructors were introduced into the java.security.InvalidParameterException class:
The garbage collectors have got a considerable chunk of improvements (especially G1), covered by JDK 20 G1/Parallel/Serial GC changes in great details. To highlight just a few:
JDK-8210708: Use single mark bitmap in G1: G1 native memory footprint has been reduced significantly by removing one of the mark bitmaps spanning the entire Java heap. Please check the brilliant Concurrent Marking in G1 article for deep technical dive.
JDK-8292654: G1 remembered set memory footprint regression after JDK-8286115: fixes the previously introduced regression that caused significantly increased memory usage in some benchmarks.
JDK-8256265: G1: Improve parallelism in regions that failed evacuation
JDK-8137022: Concurrent refinement thread adjustment and (de-)activation suboptimal
JDK-8297247: Add GarbageCollectorMXBean for Remark and Cleanup pause time in G1: adds Remark and Cleanup time to a G1 JMX bean.
From the security perspective, it worth mentioning these changes:
JDK-8256660: Disable DTLS 1.0 by default: disables DTLS 1.0 by default by adding "DTLSv1.0" to the
jdk.tls.disabledAlgorithms
security property in thejava.security
configuration file.JDK-8290368: Introduce LDAP and RMI protocol-specific object factory filters to JNDI implementation: introduces LDAP-specific factories filter (defined by
jdk.jndi.ldap.object.factoriesFilter property
) and RMI-specific factories filter (defined byjdk.jndi.rmi.object.factoriesFilter
property). The new factory filters are consulted in tandem with thejdk.jndi.object.factoriesFilter
global factories filter to determine if a specific object factory is permitted to instantiate objects for the given protocol.
This releases proves one more time that boring is not always bad. If you want to learn more about these (and other) features in JDK-20, I would highly recommend going over Java 20 π₯± guide.
I πΊπ¦ stand πΊπ¦ with πΊπ¦ Ukraine.
No comments:
Post a Comment