Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Integrating Python and Java easily using (Micro...

Sponsored · SiteGround - Reliable hosting with speed, security, and support you can count on. →

Integrating Python and Java easily using (Micronaut) GraalPy

Avatar for Cédric Champeau

Cédric Champeau

June 06, 2025

More Decks by Cédric Champeau

Other Decks in Programming

Transcript

  1. 06/06/2025 Copyright © 2024, Oracle and/or its affiliates | Confidential:

    Internal 1 Cédric Champeau Oracle Social: @[email protected] Integrating Python and Java easily Using (Micronaut) GraalPy
  2. 06/06/2025 Copyright © 2024, Oracle and/or its affiliates | Confidential:

    Internal 2 About me - Working at Oracle Labs on Micronaut - Main focus on build plugins and dev productivitity - Formerly working at Gradle Inc - Author of static compiler of Groovy - Amateur astronomer https://www.astrobin.com/users/melix/ - Mastodon: @[email protected]
  3. 06/06/2025 Copyright © 2024, Oracle and/or its affiliates | Confidential:

    Internal 3 About Micronaut - Micronaut is focused on modern architectures like Serverless and Microservices - Also a complete framework for any type of application - Lightweight, reactive (HTTP Client/Server based on Netty) - Annotation processor to compute framework infrastructure at compile time
  4. 06/06/2025 Copyright © 2024, Oracle and/or its affiliates | Confidential:

    Internal 4 Micronaut: Build Time Framework Infrastructure Micronaut computes: - All dependency & configuration injection - Annotation metadata, meta-annotations - AOP proxies - Bean introspections - And all other framework infrastructure - Reflection, runtime proxy, and dynamic classloader free
  5. 06/06/2025 Copyright © 2024, Oracle and/or its affiliates | Confidential:

    Internal 5 Micronaut modules Interesting Micronaut modules: - Micronaut Data: AoT compilation of repositories, queries, build time validation with lightweight runtime - Micronaut Sourcegen: language-neutral API for source code generation, replacement for Lombok - Micronaut Serialization: doesn’t use reflection and allows using common annotation models including Jackson annotations, JSON-B annotations or BSON annotations - Micronaut Langchain4j: thin layer over langchain4j
  6. 06/06/2025 Copyright © 2024, Oracle and/or its affiliates | Confidential:

    Internal 6 GraalVM - High-performance JDK distribution - Increases application throughput, reduces latency, reduces memory use - Graal just-in-time (JIT) compiler that runs on top of HotSpot, written in Java - native-image ahead-of-time (AoT) compiler compiles Java applications into small self-contained native binaries
  7. 06/06/2025 Copyright © 2024, Oracle and/or its affiliates | Confidential:

    Internal 8 GraalJS, GraalPy and GraalWasm - Open Source, maintained by GraalVM team - Can run on any OpenJDK distribution - Faster on GraalVM (using Graal compiler) - Supports native image - Plugins for Maven and Gradle
  8. 06/06/2025 Copyright © 2024, Oracle and/or its affiliates | Confidential:

    Internal 9 GraalPy guides and resources https://www.graalvm.org/python/
  9. 06/06/2025 Copyright © 2024, Oracle and/or its affiliates | Confidential:

    Internal 12 GraalPy plugin - Available for Maven and Gradle - Supports venv creation and packaging
  10. 06/06/2025 Copyright © 2024, Oracle and/or its affiliates | Confidential:

    Internal 13 Micronaut Graal Languages - Initially supports Python - Exposes Python modules as beans - Deals with context creation boilerplate - Limitation: no multi-context execution
  11. 06/06/2025 Copyright © 2024, Oracle and/or its affiliates | Confidential:

    Internal 14 Pros and Cons Microservices • ± Independent processes • - Inter process communcation overhead • - Data copy / synchronization / file I/O • + Free to use language runtime for each service Embedded Graal Languages • + All-in-one process, simple deployment • + Low-overhead calls between languages • + Direct data sharing • - Limited to available runtimes and versions of Graal languages • - Native libs sometimes hard to support
  12. 06/06/2025 Copyright © 2024, Oracle and/or its affiliates | Confidential:

    Internal 15 Threading model • Python has a single thread execution lock • Multiple threads in Java → have to wait for lock – Simple but low throughput • Solution: context pooling (each context is independent) • Beware: not compatible with some Python native libraries!
  13. 06/06/2025 Copyright © 2024, Oracle and/or its affiliates | Confidential:

    Internal 16 So what’s the catch? • Many Python libraries are actually native (C) • Need to recompile Python packages • Can be slow, or sometimes fail (e.g no Tensorflow for now) • Team is working on precompiled wheels (published to Maven Central or something else)
  14. 06/06/2025 Copyright © 2024, Oracle and/or its affiliates | Confidential:

    Internal 17 Compatibility • Supports Python 3.11 (3.12 in progress) • Easy upgrade from Jython • Compatible with the top 500 packages on PyPi – See graalvm.org/python/compatibility • Native extensions have to be rebuild from source
  15. 06/06/2025 Copyright © 2024, Oracle and/or its affiliates | Confidential:

    Internal 18 Resources • GraalPy Quickstart and Guides: https://www.graalvm.org/python/ • Demos: https://github.com/graalvm/graal-languages-demos/ • Micronaut GraalPy: https://micronaut-projects.github.io/micronaut-graal-languages/latest/guide/