Save 37% off PRO during our Black Friday Sale! »

To the Moon and Beyond With Java 17 APIs!

To the Moon and Beyond With Java 17 APIs!

Since moving to a 6 monthly release cadence, the Java platform is evolving more dynamically than ever before. It can be quite a challenge to stay on top of all the changes and new features.

In this talk we're going to explore the most important developments in the Java API: which classes have been added, what has been removed? Join Duke, the Java mascot for a trip to space and learn which exciting new APIs provided by the Java platform can help him with his journey:

- The Java Vector API for utilizing the SIMD capabilities of modern CPU architectures
- The Foreign Linker API for integrating with native code
- The JFR Event Streaming API for publishing JDK Flight Recorder Events

We'll also take a look at some useful changes to the Java runtime, such as CDS archives for a faster spaceship..., uhm, application launch.

8e25c0ca4bf25113bd9c0ccc5d118164?s=128

Gunnar Morling

September 28, 2021
Tweet

Transcript

  1. To the Moon and Beyond With Java 17 APIs! Gunnar

    Morling Software Engineer, Red Hat @gunnarmorling
  2. None
  3. None
  4. #Java17APIs @gunnarmorling “Commit [ourselves] to achieving the goal, before this

    decade talk is out, of landing a man Duke on the Moon and returning him safely to the Earth” Today’s Mission John F. Kennedy
  5. The Vector API 1 JFR Event Streaming 2 3 The

    Foreign Linker API
  6. #Java17APIs @gunnarmorling • Projects ◦ Debezium ◦ Quarkus ◦ Hibernate

    • MapStruct, JfrUnit, kcctl • Java Champion • @gunnarmorling Gunnar Morling Open Source Software Engineer at Red Hat
  7. The Vector API 1

  8. #Java17APIs @gunnarmorling The Vector API JEPs 338 / 414 /

    417 java.util.Vector?!
  9. #Java17APIs @gunnarmorling “Introduce an API to express vector computations that

    reliably compile at runtime to optimal vector instructions on supported CPU architectures, thus achieving performance superior to equivalent scalar computations.” The Vector API JEPs 338 / 414 / 417 JEP 417
  10. #Java17APIs @gunnarmorling The Vector API Goals Clear and concise API

    1 Reliable runtime compilation and performance on x64 (SSE, AVX) and AArch64 (NEON, SVE) 2 3 4 Platform agnostic Graceful degradation
  11. #Java17APIs @gunnarmorling The Vector API Use Cases • Image, text,

    signal processing • Encryption • Machine Learning • etc.
  12. #Java17APIs @gunnarmorling The Vector API Terminology

  13. #Java17APIs @gunnarmorling The Vector API Example – Scalar c =

    -(a2 + b2)
  14. #Java17APIs @gunnarmorling The Vector API Example – Vector

  15. #Java17APIs @gunnarmorling The Vector API Example – Vector

  16. #Java17APIs @gunnarmorling The Vector API Example – Vector

  17. #Java17APIs @gunnarmorling The Vector API Example – Vector

  18. #Java17APIs @gunnarmorling The Vector API Example – Vector

  19. #Java17APIs @gunnarmorling The Vector API A Very Rich API

  20. #Java17APIs @gunnarmorling The Vector API Example – FizzBuzz

  21. #Java17APIs @gunnarmorling The Vector API FizzBuzz – Performance Benchmark Mode

    Cnt Score Error Units scalarFizzBuzz thrpt 5 2204774,792 ± 76581,374 ops/s simdFizzBuzz thrpt 5 8830433,250 ± 69955,161 ops/s MacBook Pro 2019 (2,6 GHz 6-Core Intel Core i7, 32GB RAM)
  22. #Java17APIs @gunnarmorling The Vector API Examining Assembly Code with Hsdis

  23. #Java17APIs @gunnarmorling The Vector API Examining Native Assembly "conditionally copies

    byte elements from the source operand to the destination operand depending on mask bits defined in the implicit third register argument" felixcloutier.com
  24. Detour Identifying JDK API Changes by Yourself

  25. #Java17APIs @gunnarmorling Detour: Identifying API Changes javaalmanac.io

  26. #Java17APIs @gunnarmorling Detour: Identifying API Changes github.com/AdoptOpenJDK/jdk-api-diff

  27. #Java17APIs @gunnarmorling Detour: Identifying API Changes chriswhocodes.com/jepsearch.html

  28. #Java17APIs @gunnarmorling Detour: Identifying API Changes JavaDoc ab Version 17

  29. 1 JFR Event Streaming 3 2 The Vector API The

    Foreign Linker API
  30. #Java17APIs @gunnarmorling • Accessing native Memory (JEP 383) • Accessing

    native APIs (JEP 389) ◦ Moving specific parts to native code ◦ Using existing native libraries • Vector API Projekt Panama Integration of JVM and Native Code
  31. #Java17APIs @gunnarmorling Foreign Linker API Using Method Handle

  32. #Java17APIs @gunnarmorling Foreign Linker API Using Method Handle

  33. #Java17APIs @gunnarmorling Foreign Linker API Using Method Handle

  34. #Java17APIs @gunnarmorling • Provide or create header file • Generate

    binding (Panama EA build required) Foreign Linker API jextract
  35. #Java17APIs @gunnarmorling Foreign Linker API jextract

  36. #Java17APIs @gunnarmorling Foreign Linker API github.com/sundararajana/panama-jextract-samples

  37. Detour Removed APIs

  38. #Java17APIs @gunnarmorling • RMI Activation • Pack 200 • Nashorn

    JavaScript-Engine • Deprecated for Removal in Java 17 ◦ Applet API ◦ Security Manager Detour: Removed APIs Tackling the Maintenance Burden → 🤷 → 🤷 → Standalone Nashorn (ab Java 15), GraalJS
  39. 1 JFR Event Streaming 2 3 The Vector API The

    Foreign Linker API
  40. #Java17APIs @gunnarmorling OpenJDK Flight Recorder • “JVM framework for troubleshooting,

    monitoring and profiling” • 150+ built-in event types • Support for custom events • Open source since Java 11 • Meant for “Always on” usage in production
  41. #Java17APIs @gunnarmorling JFR Event Types https://bestsolution-at.github.io/jfr-doc/

  42. #Java17APIs @gunnarmorling JFR Event Streaming JEP 349 • Processing JFR

    events in “real-time” • Use Cases ◦ Export to monitoring services ◦ Performance tests (JfrUnit) ◦ Predictive analytics
  43. #Java17APIs @gunnarmorling JFR Event Streaming API

  44. #Java17APIs @gunnarmorling JFR Event Streaming Out-of-process: github.com/flight-recorder/health-report

  45. #Java17APIs @gunnarmorling • Performance tests based on metrics like latency/throughput

    often unstable • JfrUnit ◦ Assertions based on proxy metrics ◦ Plain JUnit-Tests ◦ Analysis via JDK Mission Control JFR Event Streaming Use Case: Performance Regression Tests with JfrUnit “Unit testing, for performance”
  46. #Java17APIs @gunnarmorling JFR Event Streaming Asserting Socket IO with JfrUnit

  47. #Java17APIs @gunnarmorling JFR Event Streaming Asserting Socket IO with JfrUnit

  48. #Java17APIs @gunnarmorling JFR Event Streaming Asserting Socket IO with JfrUnit

  49. #Java17APIs @gunnarmorling JFR Event Streaming Asserting Socket IO with JfrUnit

  50. #Java17APIs @gunnarmorling JFR Event Streaming Asserting Socket IO with JfrUnit

  51. #Java17APIs @gunnarmorling JFR Event Streaming Asserting Socket IO with JfrUnit

  52. Detour AppCDS

  53. #Java17APIs @gunnarmorling • Class Data Sharing: Memory mapped class metadata

    • Default CDS archive for JDK classes since Java 12 (JEP 341) • AppCDS: CDS archive for your own classes Detour: Faster Start-up with AppCDS No Need to Go Native?
  54. #Java17APIs @gunnarmorling Detour: AppCDS Quarkus App – Time to First

    Response Hetzner Cloud CX4 (4 vCPUs, 16GB RAM)
  55. #Java17APIs @gunnarmorling Detour: AppCDS Start-up Time of Apache Kafka

  56. None
  57. #Java17APIs @gunnarmorling Java 17 – An Update Well Worth It!

    Many Improvements Across the Board... Language API Runtime
  58. #Java17APIs @gunnarmorling • Shenandoah GC • JFR support for native

    GraalVM binaries • AArch64/Linux port • Project Lilliput Red Hat & OpenJDK Multiple Contributions
  59. #Java17APIs @gunnarmorling • JEP Search https://chriswhocodes.com/jepsearch.html • Blog (Vector API,

    JFR Event Streaming, AppCDS, etc.) https://www.morling.dev/ • JfrUnit https://github.com/moditect/jfrunit Resources
  60. #Java17APIs @gunnarmorling Q&A gunnar@hibernate.org @gunnarmorling 📧 Contact

  61. None