bytedeco/javacpp

Integration of JavaCPP fails for Eclipse/OSGi application

Open

#506 opened on Jul 14, 2021

View on GitHub
 (43 comments) (0 reactions) (1 assignee)Java (620 forks)batch import
enhancementhelp wanted

Repository metrics

Stars
 (4,279 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

I'm trying to integrate bytedeco/cpython into an Eclipse based application (which uses the Equinox OSGi runtime, like all other Eclipse applications too). Even tough I tried multiple different approaches to integrate cpython and javacpp, but non of them was successful:

  • include it via the Target-Platform
  • embed the main jars directly into a Eclipse plugin and the platform specific jars in corresponding fragments
  • embed the unpacked content of the jars in corresponding Eclipse plug-ins/fragments

All suffered the same problem: the javacpp.Loader cannot handle URL's using the bundleresource schema (like bundleresource://491.fwk108568334:2/org/bytedeco/javacpp/windows-x86_64/api-ms-win-crt-locale-l1-1-0.dll) properly. These URLs are returned by the EquinoxClassLoader used by Eclipse when the javacpp.Loader quires resources in its findResources() methods. With those URLs the caching of packages fails and the libraries cannot be loaded.

Therefore my question is: Is it possible to use javacpp and its preset in an Eclipse/OSGi application? And if yes are there some best-practices how to integrate them? I noticed you have a osgi branch where some contributions were made some time ago, but it seems to be stale and I could not find information how to use the current main artefacts in Eclipse/OSGi.

If it is not possible yet, one solution to solve the problem mentioned above could be to include org.eclipse.platform:org.eclipse.osgi as optional dependency and use the org.eclipse.osgi.storage.url.BundleURLConverter to resolve bundleresource URLs if that class is available at runtime (if it cannot be loaded it is likely that it is not required).

If the suggested change is suitable and wanted, I can create a PR for it.

I'm not sure this is the onyl required step to enable the use of javacpp in Eclipse but, it seems like it is a necessary first one.

Contributor guide