Home / Companies / Expo / Blog / Post Details
Content Deep Dive

Inside the new JNI layer in Expo Modules 2.0

Blog post from Expo

Post Details
Company
Date Published
Author
Łukasz Kosmaty
Word Count
3,249
Company Posts That Month
3
Language
English
Hacker News Points
-
Post removed?
No
Summary

Kolibri is a lightweight C++20 JNI library created for Expo Modules 2.0 on Android to replace fbjni and reduce overhead in communication among Kotlin, C++, and JavaScript. While JNI is required for Android’s Java-native boundary, its safety mechanisms and wrapper libraries can add significant costs through repeated environment lookups, exception checks, reference management, and object construction. Kolibri combines optional safety features with low-level control, allowing developers to retain managed references and exception handling where useful while omitting them in performance-critical paths. Its Kotlin compiler plugin passes C++ pointers directly to native methods for hybrid objects, while lifecycle scopes release resources associated with a destroyed JavaScript runtime and help prevent use-after-free errors. Rather than constructing Java objects through many JNI calls, Kolibri transfers JavaScript data to Kotlin through a shared direct binary buffer, reducing boundary-crossing work. Benchmarks reported by Expo show Kolibri matching raw JNI performance for C++-to-Java calls, making Kotlin-to-C++ hybrid-object calls 28 to 51 times faster than fbjni, and transferring JavaScript objects to Kotlin 3 to 5 times faster than JNI-based object construction, though it introduces an additional library and is intentionally specialized rather than general-purpose.

Trends Found in this Post

No tracked trend matches for this post yet.

Use This Data

Use this post, company, and trend context to find content marketing opportunities, perform competitive analysis, or address product feature gaps via the Plushcap MCP server or the Plushcap API.