Skip to content

jsorel/dggal-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dggal-java

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.

Panama

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.

BGen

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);
    }

Build

Requirements :

Run the following command in the root directory :

mvn clean install

Produced java library will be located in ./target/dggal-X.X.X.jar

Testing

A simple class which you can modify to test the library is located here :

src/main/java/org/dggal/Main.java

About

Java binding for DGGAL

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages