Coder Social home page Coder Social logo

adamheinrich / native-utils Goto Github PK

View Code? Open in Web Editor NEW
245.0 245.0 88.0 19 KB

A simple library class which helps with loading dynamic JNI libraries stored in the JAR archive

Home Page: https://www.adamheinrich.com/blog/2012/12/how-to-load-native-jni-library-from-jar/

License: MIT License

Java 100.00%

native-utils's People

Contributors

adamheinrich avatar andreblanke avatar andrewdavidmackenzie avatar bsqql123 avatar chibicitiberiu avatar flyhard avatar izzette avatar simonlarsen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

native-utils's Issues

Auto map Library Name for different platform

hi
What a good library the NativeUtils is!
NativeUtils works pretty nice.

By using code below,I can load different native library on different platform.
is that necessary to encapsulate System.mapLibraryName() into NativeUtils?

// mapLibraryName() return a platform-dependent native library name
// we get "libHelloJNI.dll" on windows
// we get "libHelloJNI.so" on linux
String libraryName = System.mapLibraryName("libHelloJNI");
NativeUtils.loadLibraryFromJar("/"+libraryName);

thread safety?

In my app, I'm seeing loadLibraryFromJar called in multiple places such that I'm getting multiple instances of the temp file from the same process. I'm not sure if that's a problem, but I'd appreciate some advice.

Should I wrap code which calls loadLibraryFromJar in a synchronized method and/or have a check to avoid calling this repeatedly? Relatedly, is there a reason neither of these approaches are implemented in native-utils itself?

publish to m2/jcenter

Currently we all have to copy the class into our source. This is unnecessary work & pollutes the codebase

Can u publish this into a maven central (m2) repository

4th test fail

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running cz.adamh.utils.NativeUtilsTest
Tests run: 4, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.039 sec <<< FAILURE! - in cz.adamh.utils.NativeUtilsTest
testLoadLibraryNullPath(cz.adamh.utils.NativeUtilsTest)  Time elapsed: 0.005 sec  <<< ERROR!
java.lang.Exception: Unexpected exception, expected<java.lang.NullPointerException> but was<java.lang.IllegalArgumentException>
	at cz.adamh.utils.NativeUtils.loadLibraryFromJar(NativeUtils.java:78)
	at cz.adamh.utils.NativeUtilsTest.testLoadLibraryNullPath(NativeUtilsTest.java:27)


Results :

Tests in error: 
  NativeUtilsTest.testLoadLibraryNullPath »  Unexpected exception, expected<java...

Tests run: 4, Failures: 0, Errors: 1, Skipped: 0

Got this while running maven goal on your project. I guess the IllegalArgumentException is ok because of main sources, but the tests maybe need to be corrected.

Performance impacts

Are they any benchmarks of the performance impacts of using this library rather than loading the library "normally", not from the .jar?

Has anyone got an intuition as to its performance impact?

multi-process safety?

If multiple process invoke 'NativeUtils.loadLibraryFromJar' at the same time, how to ensure the so file consistency?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.