SoftwareMill
Read post

Welcome to Panama

JEP-454 introduced the Foreign Function & Memory (FFM) API as a stable feature in JDK 22, offering a cleaner alternative to JNI for calling native code from Java. The article walks through three approaches: traditional JNI (requiring C headers, glue code, and manual compilation), manual Panama using MethodHandle and FunctionDescriptor, and automated binding generation via jextract. JMH benchmarks using the `pow` function from libm.so show that Panama's `invokeExact` and type-matching `invoke` paths achieve ~29.5 ns/op versus ~34.7 ns/op for JNI. Profiler analysis reveals the actual native call overhead is ~12.5 ns for Panama versus ~17.5 ns for JNI — roughly a 30% reduction. The performance gain is attributed to the JIT compiler's ability to optimize the `nep_invoker_blob` stub more aggressively than JNI's `native_wrapper`.

    #java#jvm
Feb 23•10m read time•From softwaremill.com
Post cover image
Table of contents
EnvironmentExampleComparisonConclusion
867 Impressions
SoftwareMill's image
SoftwareMill

SoftwareMill is a software consultancy specializing in custom software development and distributed s...

41 Followers

•

639 Upvotes

Would you recommend this post?

Copy link
WhatsApp
Facebook
X
New Squad
  • © 2026 Daily Dev Ltd.
  • Guidelines
  • Explore
  • Tags
  • Sources
  • Squads
  • Leaderboard