From ce542531f4cb6fe2bf37f3926ea869722e5acf7d Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 29 Jun 2023 02:18:18 +0200 Subject: GlueGen LibraryOnLoad Config: Generate `JNI_OnLoad(..)` for dynamic and `JNI_OnLoad_(..)` for static libraries and `JVMUtil_GetJNIEnv(..)` to resolve the `JNIEnv*` as used by JavaCallback --- doc/GlueGen_Mapping.md | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'doc/GlueGen_Mapping.md') diff --git a/doc/GlueGen_Mapping.md b/doc/GlueGen_Mapping.md index 5503db3..ee23845 100644 --- a/doc/GlueGen_Mapping.md +++ b/doc/GlueGen_Mapping.md @@ -36,6 +36,8 @@ GlueGen also supports [producing an OO-Style API mapping](#oo-style-api-interfac GlueGen is capable to bind low-level APIs such as the Java Native Interface (JNI) and the AWT Native Interface (JAWT) back up to the Java programming language. +Further, GlueGen supports generating `JNI_OnLoad(..)` for dynamic and `JNI_OnLoad_(..)` for static libraries via [`LibraryOnLoad Bindingtest2`](#libraryonload-librarybasename-for-jni_onload-), which also provides `JVMUtil_GetJNIEnv(..)` to resolve the `JNIEnv*` as used by [Java callback methods](#java-callback-from-native-c-api-support). + GlueGen utilizes [JCPP](https://jogamp.org/cgit/jcpp.git/about/), migrated C preprocessor written in Java. GlueGen is used for the [JogAmp](https://jogamp.org) projects @@ -794,7 +796,20 @@ public interface Bindingtest2 { *TODO: Work in progress* -#### Example +## Misc Configurations + +### `LibraryOnLoad ` for `JNI_OnLoad*(..)` ... + +`LibraryOnLoad ` generates native JNI code `JNI_OnLoad(..)` used for dynamic libraries, +`JNI_OnLoad_(..)` used for static libraries, +`JVMUtil_GetJNIEnv(..)` and the instance of `JavaVM* _jvmHandle`. + +The `JNI_OnLoad*(..)` methods set the `JavaVM* _jvmHandle`, which in turn is utilized by +`JVMUtil_GetJNIEnv(..)` to attach a new thread to the `JavaVM*` generating a new `JNIEnv*`in daemon mode - +or just to retrieve the thread's `JNIEnv*`, if already attached to the `JavaVM*`. + +The `LibraryBasename` parameter is used to generate the `JNI_OnLoad_(..)` variant for statically linked libraries. +`JNI_OnLoad(..)`, `JNI_OnLoad_(..)` and `JVMUtil_GetJNIEnv(..)` ## Platform Header Files -- cgit v1.2.3