Martin Ahrer

Thinking outside the box

0001-01-01 2 min read

The following describes selected improvements of the Java language. See the Java 24 release notes. See Java Language Updates for Java SE 24.

Java 24 is introducing the following language enhancements as developer preview.

  • JEP 488 is continuing with Primitive Types in Patterns, instanceof, and switch (Second Preview). Enhance pattern matching by allowing primitive type patterns in all pattern contexts, and extend instanceof and switch to work with all primitive types.

  • JEP 492 is continuing with Flexible Constructor Bodies (Third Preview). In constructors in the Java programming language, allow statements that do not reference the instance being created to appear before an explicit constructor invocation.

  • JEP 494 is continuing with Module Import Declarations (Second Preview). Enhance 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.

  • JEP 495 is continuing with Simple Source Files and Instance Main Methods (Fourth Preview). Enhance the Java programming language so that students can write their first programs without needing to understand language features designed for large programs.

Continue reading

0001-01-01 2 min read

The following describes selected improvements of the Java platform and tooling. See the Java 24 release notes.

Java 24 is introducing the following platform and tooling enhancements.

  • JEP 472 is Prepare to Restrict the Use of JNI. Prepare to restrict the use of JNI by issuing warnings when JNI is used by code on the class path. This prepares for a future release that will throw exceptions instead of issuing warnings.

  • JEP 479 is Remove the Windows 32-bit x86 Port. Remove the Windows 32-bit x86 port (windows-x86) from the JDK.

  • JEP 483 is introducing Ahead-of-Time Class Loading & Linking. Improve startup time and time to peak performance by enabling classes to be loaded and linked ahead of time.

  • JEP 486 is Permanently Disable the Security Manager. Permanently disable the Security Manager, which has been deprecated since Java 17 and marked for removal.

  • JEP 493 is introducing Linking Run-Time Images without JMODs. Enable jlink to create run-time images without requiring JMOD files to be present, provided that the packaged modules contain the same content.

  • JEP 498 is Warn upon Use of Memory-Access Methods in sun.misc.Unsafe. Issue warnings when memory-access methods in sun.misc.Unsafe are used. This prepares for their eventual removal or restriction.

  • JEP 501 is Deprecate the 32-bit x86 Port for Removal. Deprecate the 32-bit x86 port (linux-x86) with the intent to remove it in a future release.

Continue reading

0001-01-01 2 min read

The following describes selected improvements of the Java API. See the Java 21 release notes.

Java 21 is introducing the following API/library enhancements.

  • JEP 444 Virtual threads are lightweight threads that dramatically reduce the effort of writing, maintaining, and observing high-throughput concurrent applications.

  • JEP 431 Sequenced Collections Introduce new interfaces to represent collections with a defined encounter order. Each such collection has a well-defined first element, second element, and so forth, up to the last element. It also provides uniform APIs for accessing its first and last elements, and for processing its elements in reverse order.

Continue reading

0001-01-01 1 min read
Sequenced Collection List Implementation
Unresolved directive in <stdin> - include::../../../../../../../../src/main/java/twentyone/api/SequencedCollectionApi.java[tag=sequencedCollectionListImplementation]

Collection implementations with items in defined order hat a rather inconsistent API. Those collection types now implement SequencedCollection offering methods for accessing head and tail elements and reversing the ordering.

Set types that are maintaining a sequence have their own interface SequencedSet sub-type.

Continue reading

0001-01-01 1 min read

Like platform threads, a virtual thread is also an instance of java.lang.Thread class, but does not allocate a specific OS thread and consumes much less OS resources.

Executors
Unresolved directive in <stdin> - include::../../../../../../../../src/main/java/twentyone/api/VirtualThreads.java[tag=executors]

For frameworks that are managing multi-threading it’s usually just a matter of the proper configuration to switch from platform threads to virtual threads. Spring Boot for example just requires spring.threads.virtual.enabled=true in the application configuration.

Continue reading

0001-01-01 1 min read
Record Pattern Matching With Instance Of
Unresolved directive in <stdin> - include::../../../../../../../../src/main/java/twentyone/lang/Record.java[tag=recordPatternMatchingWithInstanceOf]
Record Pattern Matching With Switch
Unresolved directive in <stdin> - include::../../../../../../../../src/main/java/twentyone/lang/Record.java[tag=recordPatternMatchingWithSwitch]

Record patterns with switch support many more additional features like when clauses. Read more on the Java 21 language document for Pattern Matching for switch Expressions and Statements.

Continue reading
Older posts Newer posts