FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

GH-882: Add support for loading native library from a user specified location by pepijnve · Pull Request #883 · apache/arrow-java · GitHub

GH-882: Add support for loading native library from a user specified location - #883

Merged
lidavidm merged 1 commit into
apache:mainfrom
pepijnve:issue_882
Oct 27, 2025
Merged

GH-882: Add support for loading native library from a user specified location#883
lidavidm merged 1 commit into
apache:mainfrom
pepijnve:issue_882

Conversation

Copy link
Copy Markdown
Contributor

What's Changed

Add an opt-in code path that attempts to load the native library relative to the path specified by the arrow.cdata.library.path system property.

Closes #882.

pepijnve changed the title Add support for loading native library from a user specified location GH-882: Add support for loading native library from a user specified location Oct 10, 2025

This comment has been minimized.

lidavidm added the enhancement PRs that add or improve features. label Oct 10, 2025
github-actions Bot added this to the 18.4.0 milestone Oct 10, 2025

Copy link
Copy Markdown
Member

Is there precedent for this kind of flag in other JNI libraries?

pepijnve commented Oct 10, 2025
edited
Loading

Copy link
Copy Markdown
Contributor Author

Is there precedent for this kind of flag in other JNI libraries?

See for instance https://github.com/xerial/sqlite-jdbc/blob/755cf1d0223a83b97909fca43c8027e3e02bc021/src/main/java/org/sqlite/SQLiteJDBCLoader.java#L300 and https://github.com/jnr/jffi/blob/master/src/main/java/com/kenai/jffi/internal/StubLoader.java#L302

A possible alternative could be to check java.library.path indirectly by calling System.load first in the try/catch block. I did not go for this option since it might make existing systems pick up a library from somewhere unintentionally. The custom system property makes this explicitly opt-in.

As described in the issue, loading executable code from /tmp is problematic since it's sometimes forbidden by security settings of the host OS. This is an actual deployment problem for the system I work on since we have no control over those settings.

Copy link
Copy Markdown
Member

Thanks. I'll give this a fuller review but if there's precedent then the idea is good by me.

return;
}
} catch (UnsatisfiedLinkError e) {
// Ignore this error and fall back to extracting from the JAR file

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Actually, would it be better to error if the property is provided but the file doesn't exist? That way you don't unexpectedly/silently fall back when you intended to load from somewhere else.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

In my specific application the native library will be have been stripped from the jar and loading will fail so the end result will be the same either way.

I modeled this on examples like the ones I referenced where possible alternatives are tried in a specified order. Happy to change this to fail early though. Let me know what you would prefer.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Hmm, we can leave it as is then.

Copy link
Copy Markdown
Member

Ah, the JNI CI is still broken for now...we can queue this for after #865

Copy link
Copy Markdown
Member

Ah but in the meantime do you mind helping the linter out?

Error:  Failed to execute goal com.diffplug.spotless:spotless-maven-plugin:2.44.4:check (spotless-check) on project arrow-c-data: The following files had format violations:
Error:      src/main/java/org/apache/arrow/c/jni/JniLoader.java
Error:          @@ -91,8 +91,7 @@
Error:           ······}
Error:           ····}
Error:           
Error:          -····final·String·libraryToLoad·=
Error:          -········name·+·"/"·+·getNormalizedArch()·+·"/"·+·libraryName;
Error:          +····final·String·libraryToLoad·=·name·+·"/"·+·getNormalizedArch()·+·"/"·+·libraryName;
Error:           ····try·{
Error:           ······File·temp·=
Error:           ··········File.createTempFile("jnilib-",·".tmp",·new·File(System.getProperty("java.io.tmpdir")));
Error:  Run 'mvn spotless:apply' to fix these violations.
Error:  -> [Help 1]

Copy link
Copy Markdown
Member

Ok, please rebase and CI should be fixed!

lidavidm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

CI failure is #893

lidavidm merged commit ed81e59 into apache:main Oct 27, 2025
23 of 25 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement PRs that add or improve features.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow cdata native library to be loaded from user specified location

2 participants


Back | FazBrowse Home | New Git URL