Comments (10)
will have look into this first thing next year :)
from jnr-ffi.
I was able to work around this issue by doing the following:
ClosureManager closureManager = NativeRuntime.getInstance().getClosureManager();
val classLoader = findField(closureManager.getClass(), "classLoader");
classLoader.setAccessible(true);
val asmClassLoader = classLoader.get(closureManager);
val parent = findField(asmClassLoader.getClass(), "parent");
parent.setAccessible(true);
parent.set(asmClassLoader, Thread.currentThread().getContextClassLoader());
from jnr-ffi.
this means when we switch to the context classloader that in OSGi case it can not find its classes since OSGi does not work with context classloader at all.
but probably you are right in the respect that ClassLoader.getSystemClassLoader()
is not the right thing. I would say that getClass().getClassLoader()
is the better choice which will work when everything is loaded from the context classloader and with the OSGi case as well.
from jnr-ffi.
That would be a better default. Also, would it be possible to make this configurable maybe?
from jnr-ffi.
See contributed test case in #55.
from jnr-ffi.
Is there any update on this issue? I was trying to use jnr related java library in clojure and when i run the project with boot-clj build tool, it fails to load the class with:
java.lang.ClassNotFoundException: jnr.ffi.provider.jffi.NativeClosureProxy
java.lang.NoClassDefFoundError: jnr/ffi/provider/jffi/NativeClosureProxy
java.lang.RuntimeException: java.lang.NoClassDefFoundError: jnr/ffi/provider/jffi/NativeClosureProxy
This is because, boot-clj runs 'boot-tasks' in 'pods', which are clojure runtimes in single JVM. They are separated by different classloaders and thus the dependencies are tied to these different classloaders. The System ClassLoader does not have any libraries in the classpath and as a result, it fails to load the class.
from jnr-ffi.
Let's try fixing this with getClass().getClassLoader()
falling back on ClassLoader.getSystemClassLoader()
when that is null. I'll commit that and y'all can test it.
from jnr-ffi.
I've pushed a fix and will release 2.1.3 shortly.
from jnr-ffi.
This is not enough for OSGi running jnr as bundle, when a closure defines a return type with a Class defined in another bundle. For example:
BundleA > BundleJNR (BundleA depends on BundleJNR)
a callback on BundleA with a return type ClassA, being ClassA a class on BundleA.
JNR tries to load ClassA with the classloader of BundleJNR and fails to do it.
from jnr-ffi.
Has this issue been resolved for OSGi? I'm trying to use JavaFS which relies on this library and I continue to get The activate method has thrown an exception
The activate method has thrown an exception java.lang.RuntimeException: java.lang.NoClassDefFoundError: jnr/ffi/provider/jffi/AsmStructByReferenceFromNativeConverter
from jnr-ffi.
Related Issues (20)
- UnsatisfiedLinkError when loading 3 dependent libraries HOT 11
- Unsatisfied link when used in conjunction with jnr-posix HOT 5
- Investigate failing Pointer Boolean tests on Darwin (macOS)
- LibraryLoader.search() path not taken into consideration unless also in LD_LIBRARY_PATH HOT 3
- What's the mapping Java type of C type FILE *?
- [feature request] HOT 1
- Erorr : jnr.ffi.provider.jffi.Provider
- Native Object filling "not working"
- Native C calling Java method HOT 1
- Cannot pass a struct to 'c' function by value
- Multi-dimensional arrays as struct members HOT 1
- Load the static link library HOT 1
- Release new version of jnr-ffi HOT 1
- Why use JNR over JNA HOT 1
- support convert pointer to struct
- String parameter of a callback function gets messed when passed from DLL (Rust) to Java HOT 2
- Android and bytecode
- document build procedures
- JVM crash invoking some SDL Library function
- Bad dates in jnr/jnr-ffi commits HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jnr-ffi.