can use all the new features added from Java 12 to Java 17 • We can utilize latest ZGC to have sub 1ms GC pause time • Java 11 will EOF on 2024/10 while Java 17 will be supported till 2026 • Java 17 has improved GC performance • Frameworks/libraries may require new Java version in the future
• Switch expressions evaluate to a single value • Use “case ->” in stead of “case:” • Use “yield” instead of “return” to return value • The cases of switch expressions must be exhaustive
• Embed multi-line code snippets is a mess in previous version of Java • Text Blocks would eliminate all those obstructions • Text Blocks can be used anywhere a traditional double quote can be used
(JEP395) • Record Class is a special kind of class to model plain data aggregates • accessors/constructor/equals/hashCode/toString are created automatically • All fields are final because it’s intended to serve as data carrier
(JEP409) • Help to restrict which classes or interfaces may extend or implement • Permitted subclasses have the following constraints • Accessible by the sealed class at compile time • Directly extend the sealed class • Have exactly one of the following modifiers: • final: Cannot be extended further • non-sealed: Can be extended by unknown subclasses • sealed: Can only be extended by its permitted subclasses • In the same module/same package as the sealed class
Java 11 • ZGC is declared production ready in Java 15 • ZGC is a scalable low latency garbage collector designed to meet the goals: • Sub-millisecond max pause times • Pause times do not increase with the heap, live-set or root-set size • Handle heaps ranging from a 8MB to 16TB in size • Max throughput reduction < 15%
heap size (-Xmx<size>) • The heap can accommodate the live-set of your application • Enough headroom in the heap to allow allocations to be serviced during GC • Use -XX:MaxRAMPercentage instead if VM has different spec Setting Heap Size
(-XX:ConcGCThreads=<n>) • This option dictates how much CPU-time the GC should be given • Too much: the GC will steal too much CPU-time from the application • Too little: the application might allocate garbage faster than the GC can collect it Setting Concurrent GC Threads
'AES/CTR’ does not support padding (we were using AES/CTR/PKCS5Padding before to be backward-compatible with legacy code) AES/CTR/PKCS5Padding is not supported
LTS • SonarQube does not support Java 17 until 9.x • However, latest SonarQube LTS is 8.9 • Good news: SonarQube can still scan our codebase • Bad news: only 9.x support new features in Java 16/17
errors and solutions • ZGC - The Next Generation Low-Latency Garbage Collector • GC progress from JDK 8 to JDK 17 • Why and How to Upgrade to Java 16 or 17 • How much faster is Java 17?