Skip to content
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

generate and package jni lib in jar + load lib from jar without assuming it in java.library.path #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rdhabalia
Copy link
Contributor

Can't use artifact as it as:
When we build circe-crc32c-sse42 using maven build:

  • It internally generates "jni" library based on OS where we build and it packages this generated jni library under .nar artifact. e.g: circe-crc32c-sse42.nar
  • Nar Plugin goal also generates NarSystem.java which tries to load this jni library at runtime using System.loadLibrary("circe-crc32c-sse42-0.1-SNAPSHOT"); which fails obviously because it asks ClassLoader to load library from java.library.path or sun.boot.library.path. And as this jni library is packaged under .nar so, definitely it is not present in either library.path and hence, initialization of the interface which provides API to compute checksum Sse42Crc32C.java fails.

Solution

  • So, I created a pull request : which generates circe-crc32c-sse42.jar instead circe-crc32c-sse42.nar artifact and internally loads generated jni library without messing up with library.path and user can use this artifact without performing any additional magic.
    I have also added a test case which cleanly uses Sse42Crc32C.java to compute checksum by simply adding dependency of artifact com.scurrilous:circe-crc32c-sse42:${project.version} and without worrying about configuring library.path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant