It's been a little less than few weeks since JDK-23 was released and we have not covered it yet! To be fair, this is not a big deal, each new release gets more and more attention, but nonetheless! And while this one in particular may not be looking too exciting (well, mostly all the features are in preview), it is a messenger of what is coming next (and that is really thrilling).
Anyway, there are quite a few things that JDK-23 delivers.
JEP-474: ZGC: Generational Mode by Default: switches the default mode of the Z Garbage Collector (ZGC) to the generational mode. Deprecate the non-generational mode, with the intent to remove it in a future release.
- JEP-467: Markdown Documentation Comments: enables JavaDoc documentation comments to be written in Markdown rather than solely in a mixture of HTML and JavaDoc @-tags.
To be fair, for many (myself included), writing the documentation in such a weird mix of HTML and @-tags was never a pleasant exercise. But Markdown is a game changer here: widely used and human friendly, it has all the potential to be adopted as a go-to documentation format for JVM.
JEP-471: Deprecate the Memory-Access Methods in sun.misc.Unsafe for Removal: deprecates the memory-access methods in sun.misc.Unsafe for removal in a future release. These unsupported methods have been superseded by standard APIs, namely the VarHandle API (JEP-193 delivered in JDK-9) and the Foreign Function & Memory API (JEP-454 delivered JDK-22).
- JEP-476: Module Import Declarations (Preview): enhances the Java programming language with the ability to succinctly import all of the packages exported by a module. This simplifies the reuse of modular libraries, but does not require the importing code to be in a module itself. This is a preview language feature.
This is more of usability feature that replaces mass imports with a single line, for example:
import module java.base;
But taking into account relatively limited adoption of the JPMS, its usefulness is a bit unclear at the moment.
- JEP-455: Primitive Types in Patterns, instanceof, and switch (Preview): enhances pattern matching by allowing primitive type patterns in all pattern contexts, and extend
instanceof
andswitch
to work with all primitive types. This is a preview language feature.The work under this JEP lifts off one of the JEP-411 (that was delivered in JDK-21) restrictions and allows using primitive types in
instanceof
andswitch
statements and/or expressions, for example:
final Object obj = ... ; var o = switch (obj) { case null -> ... ; case String s -> ... ; case byte b -> ... ; case int[] a -> ... ; default -> ... ; }
JEP-466: Class-File API (Second Preview): refinements over JEP-457 that was delivered in JDK-22.
JEP-469: Vector API (Eighth Incubator): refinements over JEP-460 that was delivered in JDK-22.
JEP-473: Stream Gatherers (Second Preview): refinements over JEP-461 that was delivered in JDK-22.
JEP-477: Implicitly Declared Classes and Instance Main Methods (Third Preview): refinements over JEP-463 that was delivered in JDK-22.
JEP-480: Structured Concurrency (Third Preview): refinements over JEP-462 that was delivered in JDK-22.
JEP-481: Scoped Values (Third Preview): refinements over JEP-464 that was delivered in JDK-22.
JEP-482: Flexible Constructor Bodies (Second Preview): refinements over JEP-447 that was delivered in JDK-22.
Along with the new features, there are some disruptive changes as well, notably:
JDK-8325568: Remove legacy locale data (COMPAT, JRE) from the JDK: removes legacy locale data. As the result, setting
java.locale.providers
system property toJRE
orCOMPAT
(e.g.,java -Djava.locale.providers=JRE,CLDR ...
orjava -Djava.locale.providers=COMPAT,CLDR ...
) will have no effect (ignored). Check please Unicode in JDK 23: Removal of COMPAT Locale Provider for more details.JDK-8296244: Alternate implementation of user-based authorization Subject APIs that doesn’t depend on Security Manager APIs: in the implementation of
Subject.current()
andSubject.doAs()
, replaces the dependencies onAccessController
/AccessControlContext
(which are deprecated for removal) with scoped values (see JEP-446).In scope of this change, the terminally deprecated method
Subject.getSubject(AccessControlContext)
has been respecified to throw UnsupportedOperationException if invoked when a Security Manager is not allowed. Check please JDK23: Re-Specified Subject.getSubject API for more details.JDK-8341127: Extra call to MethodHandle::asType from memory segment var handles fails to inline: a misfortunate performance regression has slipped into JDK-23 release when using memory segment var handles.
The following methods have been removed from java.lang.Thread class:
void resume()
void suspend()
Consequently, the following methods have been removed from java.lang.ThreadGroup class:
void resume()
void suspend()
void stop()
The javax.management.remote.rmi.RMIConnector lost one method as part of JDK-8326666: Remove the Java Management Extension (JMX) Subject Delegation feature:
MBeanServerConnection getMBeanServerConnection(javax.security.auth.Subject subject)
JDK-8318966: Some methods make promises about Java array element alignment that are too strong removes the following methods:
java.lang.invoke.MethodHandles::byteArrayViewVarHandle
java.lang.invoke.MethodHandles::byteBufferViewVarHandle
java.nio.ByteBuffer::alignedSlice
java.nio.ByteBuffer::alignmentOffset
JDK-8330005: RandomGeneratorFactory.getDefault() throws exception when the runtime image only has java.base module: moves all random generators mandated in package
java.util.random
and currently implemented in modulejdk.random
to modulejava.base
, and removes modulejdk.random
.JDK-6968351: httpserver clashes with delayed TCP ACKs for low Content-Length: avoids immediately sending response headers if chunked mode is selected or if the response has a body.
On the bright side, there are a number of enhancements, bug fixes, tooling and GC improvements that are worth mentioning:
JDK-8326908: DecimalFormat::toPattern throws OutOfMemoryError when pattern is empty string: for java.text.DecimalFormat created with an empty String pattern, the value returned by java.text.DecimalFormat::getMaximumFractionDigits will now be
340
, instead of the previous value,Integer.MAX_VALUE
.JDK-8319548: Unexpected internal name for Filler array klass causes error in VisualVM: adds the
[
array bracket, and renames the element name to not have Array inside to not try to pretend that the element is some other kind of array.JDK-8331048: G1: Prune rebuild candidates based on G1HeapWastePercent early: reduces the rebuild time in cases where pruning happens.
JDK-8327452: G1: Improve scalability of Merge Log Buffers: reduces contention on the dirty card queue set (DCQS).
JDK-8280087: G1: Handle out-of-mark stack situations during reference processing more gracefully: allows for growing the marking stack without the need to copy over elements.
JDK-8329203: Parallel: Investigate Mark-Compact for Full GC to decrease memory usage: transitions to the mark-compact algorithm (the same one used in Serial/G1 full-GC) that mitigates the memory footprint and bring it more in line with other garbage collectors.
JDK-8325553: Parallel: Use per-marker cache for marking stats during Full GC: adds cache to avoid too much contentious writes to global marking stats.
JDK-8275338: Add JFR events for notable serialization situations: adds serialization misdeclaration events to JFR.
JDK-8319551: Regressions >10% in some JFR Startups: fixes regression introduced in JDK-22, making startup times comparable to JDK-21.
JDK-8324665: Loose matching of space separators in the lenient date/time parsing mode: implements CLDR loose matching on parsing in DateFormat/DateTimeFormatter.
JDK-8332154: Memory leak in SynchronousQueue: SynchronousQueue sometimes appears in a state where it has only request nodes (i.e. it is empty) and a reference to an item it stored before.
JDK-8330542: Template for Creating Strict JAXP Configuration File: adds a template for users to create custom JAXP configuration files, that can then be used to test and verify the readiness of their applications before the JDK's eventual switch to a more secure configuration by default:
jaxp-strict.properties.template
.
The changes on the standard library API side are quite moderate:
The true gem of JDK-23 is brand new utility class java.lang.runtime.ExactConversionsSupport that helps to test if conversion of a value is exact (it yields a result without loss of information or throwing an exception).
The java.io.Console class has gained a lot of new methods under JDK-8330276 Console methods with explicit Locale:
A sealed interface java.lang.foreign.MemorySegment was enriched with one new method:
An interface java.lang.foreign.SymbolLookup had one new default method:
An abstract class java.text.NumberFormat got some new functionality:
Consequently, its subclasses java.text.CompactNumberFormat, java.text.DecimalFormat and java.text.ChoiceFormat inherited (and implemented) these new APIs as well.
An old java.net.Inet4Address class also got one new factory method:
Quite useful enhancement went into java.time.Instant class as part of JDK-8331202: Support for Duration until another Instant:
The class javax.tools.SimpleJavaFileObject was empowered with a new factory method:
On the final note, it is good time to go over some security related updates that were introduced into JDK-23 (for more details, please check JDK 23 Security Enhancements):
JDK-8330108: Increase CipherInputStream buffer size: increases buffer size in CipherInputStream from 512 bytes to 8192 bytes.
JDK-8328638: Fallback option for POST-only OCSP requests: introduces a new JDK system property
com.sun.security.ocsp.useget
to allow clients to fallback to POST-only behavior:-Dcom.sun.security.ocsp.useget={false,true}
(the default value istrue
).JDK-8051959: Add thread and timestamp options to java.security.debug system property: improves the
java.security.debug
output so that options exist to add thread ID, thread name, source of log record and a timestamp information to the output.
If anything, JDK-23 is a solid release, ready for prime time. From the changes perfective, it looks low risk as well, so if you skipped JDK-22 for some reasons, JDK-23 may be the one.
I πΊπ¦ stand πΊπ¦ with πΊπ¦ Ukraine.
No comments:
Post a Comment