Sailing Modern Java
Conference (INTERMEDIATE level)
Room 3
Score 0.16
Score 0.16
Score 0.18
Score 0.19
The match becomes increasingly accurate as the similarity score approaches zero.

Another (half a) year has passed, another major Java™ version has been released. Java was supposed 'to be slow'. However, Java turns out to evolve so fast, that next releases aren't just version bumps, but might significantly change the rules of the game. That's a good reason to check out what's new in Java. We're going to cover some features of recent Java versions:

  • Pattern Matching for switch,
  • Record Patterns,
  • Virtual Threads,
  • Calling native stuff,
  • Simple Web server,
  • what's gone and what will be gone,
  • and other stuff.
Piotr Przybyl

Notorious engineer at work and after hours, tracing meanders of the art of software engineering. Remote Software Gardener, mostly working in web-oriented Java gardens. Programming usually in Java (since 1.3) and Scala, but in other languages too. Fan of agility, seen mostly as choosing the right tools and approaches after asking the right questions. Developer, trainer and conference speaker. In his talks, Piotr covers not only hardcore Java but also software architecture, computer security, and soft-skills.

Generated Summary
WARNING: This summary was generated using GPT based on the transcript, as a result spelling mistakes and more importantly hallucinations can be present.

Java Versions 19 and 20
John, a software engineer and trainer for Atomic Jar, introduces the last session of the day focused on the latest Java versions 19 and 20. He encourages the audience to switch to the latest Java version for better performance and other benefits. He also introduces a new feature called Project Loom which is a new concurrency structure or idiom that allows for more threads per request.
Language Syntax Changes
There have been no new language syntax changes, however, there are new features such as pattern matching and native call improvements. To enable these features, you must have the proper Java version installed and use the enable preview flag. This change has sparked debate as to whether it is the biggest change since Lambda was introduced in Java 8.
Virtual Threads
Virtual threads are the new form of threads in concurrency, replacing the older \"fiber\" model. They are designed to be easier to start, faster, and have less overhead than traditional threads. They cannot be changed in terms of priority or demon status, and are meant to be used in places where a thread is waiting for an operation such as data from storage or a network call. In Java 19 and 20 there is an option to opt out of thread locals, however this will not be available in Java 21. To use virtual threads, developers must go into their source code and tell the program to use virtual threads instead of new threads. This can be done with the \"start virtual thread\" command, or by using an executor. A factory can also be created for virtual threads if needed.
Testing Virtual Threads
To test virtual threads, developers can use a dummy example of a microservice with an HTTP server and Toxic Proxy to create a latency of half a second. This will show if any core colors of the HTTP client become blocked and therefore pinned. Test containers can also be used to help with this testing process. To detect if virtual threads are pinned, one can use JDK Trace or Java Flight Recorder events.
Java 16 and 20
Java 16 now offers Structured Concurrency and a Record data carrier as a standard. Java 20 has introduced pattern matching for switch and record patterns which is more null friendly and allows for combining null and default. It also handles objects, not just primitives, and does not allow for fall through. It works with both switch expression and switch instructions, as well as records and nesting. Native code can be tedious, unsafe, limited and slow, but Java 20 has introduced new native features to improve speed, safety and usability. The Java Foreign Function and Memory API has been around for at least six releases and provides a way to access native memory.
The talk provided an overview of the latest Java versions 19 and 20 and the new features they offer. It offered suggestions on how to test virtual threads and introduced changes and improvements to the language syntax. It concluded with an invitation to participate in an anonymous survey and follow the speaker on social media for more IT tips and pool life advice.
You can also ask questions on the complete talk using Devoxx Insights