What this book covers
Chapter 1, Text Blocks, Locales, Numbers, and Math, includes 37 problems covering 4 main topics, text blocks, locales, numbers, and mathematical operations.
Chapter 2, Objects, Immutability, Switch Expressions, and Pattern Matching, includes 30 problems tackling, among other things, some less-known features of java.util.Objects
, some interesting aspects of immutability, the newest features of switch
expressions, and deep coverage of the pattern matching expressions; instanceof
and switch
.
Chapter 3, Working with Date and Time, includes 20 problems covering different date-time topics. These problems are mainly focused on the Calendar API and the JDK 8 Date/Time API. About the latter, we will cover some of the less-studied APIs like ChronoUnit
, ChronoField
, IsoFields
, and TemporalAdjusters
.
Chapter 4, Records and Record Patterns, includes 19 problems that cover in detail the Java records introduced in JDK 16 (JEP 395) and record patterns, which were introduced as a preview feature in JDK 19 (JEP 405), as a second preview feature in JDK 20 (JEP 432), and as a final feature in JDK 21 (JEP 440).
Chapter 5, Arrays, Collections, and Data Structures, includes 24 problems covering three main topics. We start with several problems meant to cover the new Vector API dedicated to data parallel processing. We continue with several data structures including Rope, Skip List, K-D Tree, Zipper, Binomial Heap, Fibonacci Heap, Pairing Heap, Huffman Coding, and so on. Finally, we discuss the three most popular join algorithms.
Chapter 6, Java I/O: Context-Specific Deserialization Filters, includes 13 problems related to Java serialization/deserialization processes. We start with classical problems like serializing/deserializing objects to byte[]
, String
, and XML formats. We then continue with JDK 9 deserialization filters meant to prevent deserialization vulnerabilities, and we finish with JDK 17 context-specific deserialization filters.
Chapter 7, Foreign (Function) Memory API, includes 28 problems covering the Foreign Function Memory API and Foreign Linker API. We start with the classical approaches for calling foreign functions, relying on the JNI API and the open-source JNA/JNR libraries. Next, we introduce the new approach delivered under the code name Project Panama. We dissect the most relevant APIs such as Arena, MemorySegment, MemoryLayout, and so on. Finally, we focus on the Foreign Linker API and the Jextract tool for calling foreign functions that have different types of signatures, including callback functions.
Chapter 8, Sealed and Hidden Classes, includes 13 problems covering Sealed and Hidden Classes. The first 11 recipes will cover Sealed Classes, a very cool feature brought in by JDK 17 to sustain closed hierarchies. The last two problems cover Hidden Classes, a JDK 15 feature that allows frameworks to create and use runtime (dynamic) classes hidden to the JVM.
Chapter 9, Functional Style Programming – Extending APIs, includes 24 problems covering a wide range of functional programming topics. We will start by introducing the JDK 16 mapMulti()
and continue with a handful of problems for working with predicates (Predicate), functions, and collectors.
Chapter 10, Concurrency – Virtual Threads and Structured Concurrency, includes 16 problems briefly introducing virtual threads and structured concurrency.
Chapter 11, Concurrency – Virtual Threads and Structured Concurrency: Diving Deeper, includes 18 problems meant to dive deep into how virtual threads and structured concurrency work and how they should be harnessed in your applications.
Chapter 12, Garbage Collectors and Dynamic CDS Archives, includes 15 problems covering Garbage Collectors and Application Class-Data Sharing (AppCDS).
Chapter 13, Socket API and Simple Web Server, includes 11 problems covering the Socket API and 8 problems covering JDK 18’s Simple Web Server. In the first 11 problems, we will discuss implementing socket-based applications such as blocking/non-blocking server/client applications, datagram-based applications, and multicast applications. In the second part of this chapter, we discuss Simple Web Server as a command-line tool.