mirror of
https://github.com/google/brotli.git
synced 2026-07-08 17:56:58 +00:00
System.loadLibrary() not present in EncoderJNI.java ? #210
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @kjatin on GitHub (Jan 8, 2018).
I was trying to use the JNI wrapper but found that EncoderJNI.java file does not have a loadLibrary statement in a static block.
It does not work until I add the following piece of code:
static{ System.loadLibrary("myBrotliJNILibraryName"); }Any particular reason for this?
@eustas commented on GitHub (Jan 8, 2018):
There are 2 main reasons:
The solution is to let developer decide, when and what library to load. For testing we use a simple but flexible stub: https://github.com/google/brotli/blob/master/java/org/brotli/integration/BrotliJniTestBase.java#L10
@kjatin commented on GitHub (Jan 8, 2018):
Does this mean that if we want to import the source code as a third-party code, we would need to make modifications to the source code? Is there a simpler way of loading the library (something similar to the stub you mentioned). Please excuse my in-experience with JNI build systems.
@eustas commented on GitHub (Jan 8, 2018):
Yup.
It is possible to write a generalized stub, but it is a little bit scary, because:
BROTLI_JNI_LIBRARY)@kjatin commented on GitHub (Jan 12, 2018):
I get the point here. Thanks for the clarification. However I would suggest you put this instruction in the README or some other suitable file as a documentation.