Skip to content

JniGen Code Generator

gershnik edited this page Sep 30, 2019 · 6 revisions

Using SmJNI 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 annotations and an annotation processor.

The following pages describe how to set it up and use it.

Integrating JniGen
Annotations
Processor Options

Clone this wiki locally