Productivity, Sustainability, and Fun in modern Java

A presentation at Devoxx Ukraine in November 2021 in by Oleg Šelajev

Slide 1

Slide 1

Productivity, Sustainability, and Fun in modern Java Oleg Šelajev @shelajev

Slide 2

Slide 2

Developer advocate atomicjar.com testcontainers.org

Slide 3

Slide 3

Slide 4

Slide 4

Modern

Slide 5

Slide 5

About Java releases 2 releases / year Oracle LTS every 4th release Multiple vendors GraalVM

Slide 6

Slide 6

Text blocks

Slide 7

Slide 7

Records

Slide 8

Slide 8

instanceof pattern matching

Slide 9

Slide 9

Switch expressions

Slide 10

Slide 10

Pattern matching for switch

Slide 11

Slide 11

Sealed classes

Slide 12

Slide 12

Fast

Slide 13

Slide 13

Slide 14

Slide 14

Copyright © 2021, Oracle and/or its affiliates

Slide 15

Slide 15

Slide 16

Slide 16

Startup Speed Peak Throughput JIT AOT Reduced Max Latency Low Memory Footprint Small Packaging

Slide 17

Slide 17

Slide 18

Slide 18

Native Image Build Process Input: All classes from application, libraries, and VM Application Output: Native executable Points-to Analysis Ahead-of-Time Compilation Libraries Code in Text Section Run Initializations JDK Substrate VM Heap Snapshotting Iterative analysis until fixed point is reached Image Heap Writing Image Heap in Data Section

Slide 19

Slide 19

Configuring Native Image build: Reflection, Proxies, JNI, Resources, etc https://medium.com/graalvm/working-with-native-image-efficiently-c512ccdcd61b

Slide 20

Slide 20

Configuring Native Image build: Reflection, Proxies, JNI, Resources, etc java -agentlib:native-image-agent=\ config-output-dir=META-INF/native-image \ -jar App.jar https://medium.com/graalvm/working-with-native-image-efficiently-c512ccdcd61b

Slide 21

Slide 21

Slide 22

Slide 22

https://medium.com/graalvm/graalvm-21-3-is-here-java-17-native-image-performance-updates-and-more-ac4cbafcfc05

Slide 23

Slide 23

Build tools • sbt native client • • • https://www.scala-sbt.org/1.x/docs/sbt-1.4-Release-Notes.html https://asciinema.org/a/wAAYjiO0TNW0V7dCSebMQB5wa mvnd • https://github.com/mvndaemon/mvnd

Slide 24

Slide 24

GraalVM Native Image Support in the AWS SDK for Java 2.x The test application creates an S3Client with ApacheHttpClient and sends a simple GetObjectRequest. In our testing, we measured the SDK 2.x startup time and the first request latency as well as the memory usage. https://aws.amazon.com/blogs/developer/graalvm-native-image-support-in-the-aws-sdk-for-java-2-x/

Slide 25

Slide 25

Writing Kubectl plugins with Scala or Java, with Fabric8 Kubernetes client on GraalVM Rewriting a kubectl plugin from a standard Go stack to a more comfortable approach with Scala has been challenging and rewarding. We are really happy with the result, and we arguably improved it in several ways. https://www.lightbend.com/blog/writing-kubectl-plugins-with-scala-or-java-with-fabric8-kubernetes-client-on-graalvm

Slide 26

Slide 26

Lightweight

Slide 27

Slide 27

Slide 28

Slide 28

Slide 29

Slide 29

Integration tests Testcontainers Database app Kafka API

Slide 30

Slide 30

🐋 https://medium.com/@bsideup/testing-your-docker-containers-with-testcontainers-and-groovy-3b9ef97ad1c2

Slide 31

Slide 31

Local environment Testcontainers Database app Kafka API

Slide 32

Slide 32

Testcontainers Cloud https://www.atomicjar.com/2021/11/announcing-testcontainers-cloud/

Slide 33

Slide 33

Fast Modern Lightweight *