java integration via JNA
Folks at the Heavy Photon Search experiment (HPS) have developed a method to access GBL from within java using Java Native Access (JNA) to call wrapper functions built into the GBL dynamic library. The code for this is stored in GitHub repositories and I will work on porting the C++ side of things into this repository.
-
GBL on GitHub
- This repository was manually ported to GitHub from SVN and is based off v2.2.0 of GBL.
- The Java code using JNA to call the wrapper functions is in hps-java on GitHub:
Planned Updates
There are two updates that will need to be made in order to accomodate this integration.
Wrapper Functions
These are simply extra source files that wrap common accesssors and setters from the C++ classes in simply-named extern "C"
functions so that JNA can operate by calling known function names.
Updates to Initialization Procedure
Since the Java Virtual Machine (JVM) handles memory for java, we need to (slighly) update the C++ classes we wish to wrap so that the initialization of the memory they require can happen completely when they are constructed. This helps avoid memory issues when running the JVM and allowing it to interact with GBL objects.
Possible Additional Updates
I am also interested in starting a java
sub-directory of GBL, but I am currently unfamiliar with the packaging infrastructure with java and so I'm not sure if that is feasible or desirable. If I choose to not try to implement a java "package" using JNA to access the GBL C++ objects, I will document how to do it within the GBL wiki.