-
Notifications
You must be signed in to change notification settings - Fork 588
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OSGi enabled JavaCPP #332
OSGi enabled JavaCPP #332
Conversation
* Annotations are used to export packages and define versions * User implementable interfaces are marked `@ConsumerType` * Baselining is enabled to validate future package version changes Signed-off-by: Tim Ward <timothyjward@apache.org>
This test currently passes because it does not use the JavaCPP Loader to load its native libraries. Ideally this would be fixed so that users don't need to care about where they are running Signed-off-by: Tim Ward <timothyjward@apache.org>
If I understand correctly OSGi wants to manage native libraries on its own with |
So what OSGi does with I'm currently investigating the feasibility of generating a small Java Helper class to live alongside the class(es) using JavaCPP. This helper can be called to try to load the native library within the correct Class context. If you have another idea about how this could be achieved then I'd be happy to hear it! |
Signed-off-by: Tim Ward <timothyjward@apache.org>
Let's see, public static void load(String filename) {
Runtime.getRuntime().load0(getCallerClass(), filename);
} Still seems to be the same on the tip: Would you be against trying to call |
Obviously there are issues with reflectively calling the internals of the JDK (for example this may not work on Eclipse's J9) but there isn't anything that OSGi will do to stop you and it should work. My biggest concern is that this sort of thing may well not work in future versions of Java as the VM is further locked down. When it comes down to it it's your call. I'll create a PR for the "helper class" approach so that you can take a look. |
OpenJ9 uses OpenJDK, Android uses OpenJDK, there isn't much of anything that doesn't use OpenJDK these days, well maybe except IBM JDK, but they haven't updated since Java SE 8, so that's not a problem IMO. If OpenJDK ever decides to change that API, or even better, make the equivalent public, then we can always update at that point. There is still nothing to replace |
As discussed in bytedeco#332, this commit uses reflection to load native libraries using the relevant class context A similar commit is present in bytedeco#337, but this commit is designed to be applied to the master branch as part of bytedeco#332 Signed-off-by: Tim Ward <timothyjward@apache.org>
Looks good, but as I pointed out, we don't need to use try to use And could you revert the breaking changes to the manifest as well? |
As discussed in bytedeco#332, this commit uses reflection to load native libraries using the relevant class context A similar commit is present in bytedeco#337, but this commit is designed to be applied to the master branch as part of bytedeco#332 Signed-off-by: Tim Ward <timothyjward@apache.org>
Remove the name section so that all packages pick up the metadata in the manifest Signed-off-by: Tim Ward <timothyjward@apache.org>
2b6a37b
to
afa6e74
Compare
Done
Also done, but not as a revert (which results in a broken OSGi bundle and fails the integration test). Instead I have applied the same fix as is on the |
It looks like the Travis build is passing. Are you happy to merge this now? |
Following on from discussions in PR #328 this PR does not change the Maven Plugin layout and
Note that the integration test passes because the JavaCPP
Loader.load()
method is not used, if it is used then the test fails. This demonstrates how the native library loading done by JavaCPP fails in OSGi, and hopefully can be used to design a fix.