Skip to content

JniGen Code Generator

gershnik edited this page Oct 11, 2021 · 1 revision

Using SimpleJNI in your C++ code solves many problems - type safety, RAII, need to lookup classes and methods by string names etc. However, one problem still remains. For every Java entity that needs to be visible from C++ code: classes, methods, fields or native methods there is some boilerplate code to write. It's only a few lines and it closely parallels the Java code but it is tedious, repetitive and violates DRY principle. If you make a change you need to to make it twice. If you forget you'll get runtime errors. The JniGen code generator solves this issue by generating necessary boilerplate C++ code from Java automatically. It relies on Java or Kotlin annotations and a Java, KAPT or KSP annotation processors. The following pages describe how to set it up and use it.

Integrating JniGen
Annotations
Processor Options