-
Notifications
You must be signed in to change notification settings - Fork 12
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
[Bug] ClassLoader
tries to open libzenoh_jni.so
twice, crashes
#315
Comments
I see there's the Thought - could catch the |
Yes, you resumed it pretty well, we have a singleton to avoid loading multiple times the library. On top of that, Reading your error, I see that somehow you end up with multiple class loaders, I think if you only had a single class loader then the subsequent call to the library would be ignored. I wouldn't like to edit the lib to catch the UnsatisfiedLinkError because there may be situations where we want it to be thrown, for instance for Android we support a series of platforms on top of which the lib can run, what if the user wants to use it on an android device whose platform isn't supported? Then the exception should not be catched. |
Yeah, I was thinking about a fork to try handling this temporarily. I agree that catching the error is not a great final solution, even if you'd filter and rethrow.
Correct. The ATAK platform supports complete loading/unloading of plugins and their dependencies within its application lifetime. So I needed to make sure that loading/unloading Zenoh with my plugin would function. When the load/unload occurs, I get new instances of things. It's an abnormal use case, I think, but I need to find a way to handle it. If I get something working, I'll share for reference. If I don't get the time, I may just wait to see what you come up with. |
The only thing that comes to my mind to properly resolve this at first glance, is for you to handle your own class loaders, and somehow expose an API here to load the native library using a provided class loader, instead of the system's class loader. Then when the plugin is dropped, the class loader would be dropped as well (effectively unloading the library) and the problem shouldn't arise again. Tbh, we have many other priorities right now. |
Describe the bug
I'm developing an Android application plugin. Due to the nature of the base application, it's possible to unload and reload plugins. My plugin uses Zenoh,
When I reload my plugin, the
ClassLoader
attempts to open thelibzenoh_jni.so
. However, it was already opened the first time I loaded my plugin, and an exception is thrown. Ideally,libzenoh_jni.so
shouldn't be opened if it's already open - not due to my use case, but as a general safety feature.I imagine a conditional check or a try/catch around this logic would be fine to prevent the issue? I haven't had a chance to look around for where this is happening.
open for stacktrace
To reproduce
I'm not sure I have clear steps for this. I run the ATAK-CIV platform with my plugin on top of it, but it's probably unreasonable to build out a sample of that.
My steps anyway:
What would be other ways to trigger class loading?
System info
The text was updated successfully, but these errors were encountered: