Java binding for DGGAL using Panama.
This is a prototype made in collaboration with Geomatys and Ecere.
This project will be removed when Ecere Bgen tool will be able to generate the java bindings automatically.
Java Panama is the latest native mapping library. Replacing the old JNI API. Panama provides clean memory management with native code, no need to write C mapping code, no memory copy, 5 times more efficient then JNI, making the binding memory/cpu/speed cost invisible.
Known limitations :
- can't use macro obviously.
The code part which should be automatically generated is located under the comment block
// ////////////////////////////////////////////////////////////////////////
// GENERATED BY BGEN //////////////////////////////////////////////////////
// ////////////////////////////////////////////////////////////////////////
Three sections needs to be filled.
- the native function declarations :
// //////////////////////////////
// List the native functions here
// //////////////////////////////
/**
* {@snippet lang=c : extern Module dggal_init(Module fromModule) }.
*/
private final MethodHandle dggal_init;
- fetching the functions from the native library :
// ///////////////////////////////////////
// find every method in the native library
// ///////////////////////////////////////
dggal_init = lookup("dggal_init", of(C_POINTER, C_POINTER));
- offer a friendly java function :
// ///////////////////////////////////////
// make method calls more friendly
// ///////////////////////////////////////
//if a doc can be generated, it would be nice
public MemorySegment dggal_init(MemorySegment app) throws Throwable {
return (MemorySegment) dggal_init.invokeExact(app);
}
Requirements :
- JDK 22+ : https://adoptium.net/fr/temurin/releases?version=24&mode=filter&os=any&arch=any
- maven tool : https://maven.apache.org
Run the following command in the root directory :
mvn clean install
Produced java library will be located in ./target/dggal-X.X.X.jar
A simple class which you can modify to test the library is located here :
src/main/java/org/dggal/Main.java