Kotlin-JNI

Unifies JNI usage across native targets, offering rich type-conversion helpers, annotation-driven generation of C-style JNI stubs, and seamless Java-to-native calls that remove boilerplate.

Android JVMJVMKotlin/Native
GitHub stars2
Authorsdshatz
Open issues0
LicenseApache License 2.0
Creation dateabout 2 months ago

Last activityabout 2 months ago
Latest release2.0.4-rc02 (about 2 months ago)

Kotlin-JNI

Kotlin Multiplatform Android Native Linux MacOS Windows Language licence github stars

Kotlin-JNI is a powerful Kotlin Multiplatform library designed to simplify and unify JNI (Java Native Interface) development across Android, Desktop (Linux, macOS, Windows), and Kotlin/Native.

It provides a common JNI interface for all supported native targets and includes a KSP module to automatically generate JNI-compatible function stubs, eliminating boilerplate and bridging the gap between your native Kotlin code and the Java world.

Acknowledgement

I want to express great gratitude to the original creator @DatL4g for the idea and execution. This project indeed makes JNI on Kotlin painless and effortless.

However, since the original repository no longer has a permissive license, this repository had to be created, based on the older, Apache-licensed version.

✨ Features

  • Unified JNI API: Write common JNI code for androidNative, linux, macos, and mingwX64 targets.
  • Type Conversion Utilities: A rich set of extension functions to effortlessly convert between JNI types and standard Kotlin types (e.g., jstring.toKString(), IntArray.toJIntArray()).
  • KSP Code Generation: Automatically generate JNI-compatible C-style function stubs from your idiomatic Kotlin functions using the @JNIConnect annotation.
  • Seamless Java Integration: Call your native Kotlin functions directly from Java with standard Kotlin types, just as you would with any other external method.

🛠️ Setup & Usage

Please read the full documentation.

Contributions

Feel free to create Pull Requests and Issues. I will do my best to address them.

Android JVMJVMKotlin/Native
GitHub stars2
Authorsdshatz
Open issues0
LicenseApache License 2.0
Creation dateabout 2 months ago

Last activityabout 2 months ago
Latest release2.0.4-rc02 (about 2 months ago)

Kotlin-JNI

Kotlin Multiplatform Android Native Linux MacOS Windows Language licence github stars

Kotlin-JNI is a powerful Kotlin Multiplatform library designed to simplify and unify JNI (Java Native Interface) development across Android, Desktop (Linux, macOS, Windows), and Kotlin/Native.

It provides a common JNI interface for all supported native targets and includes a KSP module to automatically generate JNI-compatible function stubs, eliminating boilerplate and bridging the gap between your native Kotlin code and the Java world.

Acknowledgement

I want to express great gratitude to the original creator @DatL4g for the idea and execution. This project indeed makes JNI on Kotlin painless and effortless.

However, since the original repository no longer has a permissive license, this repository had to be created, based on the older, Apache-licensed version.

✨ Features

  • Unified JNI API: Write common JNI code for androidNative, linux, macos, and mingwX64 targets.
  • Type Conversion Utilities: A rich set of extension functions to effortlessly convert between JNI types and standard Kotlin types (e.g., jstring.toKString(), IntArray.toJIntArray()).
  • KSP Code Generation: Automatically generate JNI-compatible C-style function stubs from your idiomatic Kotlin functions using the @JNIConnect annotation.
  • Seamless Java Integration: Call your native Kotlin functions directly from Java with standard Kotlin types, just as you would with any other external method.

🛠️ Setup & Usage

Please read the full documentation.

Contributions

Feel free to create Pull Requests and Issues. I will do my best to address them.