René's URL Explorer Experiment


Title: Library reboot and much more · Issue #50 · scijava/native-lib-loader · GitHub

Open Graph Title: Library reboot and much more · Issue #50 · scijava/native-lib-loader

X Title: Library reboot and much more · Issue #50 · scijava/native-lib-loader

Description: Hello folks, I/we are trying to reboot the this library, the idea is to unify a lot of different leaf/sparse conventions all together for handling natives for the whole cycle, from the producer publication till the user consumption, sinc...

Open Graph Description: Hello folks, I/we are trying to reboot the this library, the idea is to unify a lot of different leaf/sparse conventions all together for handling natives for the whole cycle, from the producer pub...

X Description: Hello folks, I/we are trying to reboot the this library, the idea is to unify a lot of different leaf/sparse conventions all together for handling natives for the whole cycle, from the producer pub...

Opengraph URL: https://github.com/scijava/native-lib-loader/issues/50

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Library reboot and much more","articleBody":"Hello folks,\r\n\r\nI/we are trying to reboot the this library, the idea is to unify a lot of different leaf/sparse conventions all together for handling natives for the whole cycle, from the producer publication till the user consumption, since this is one of the cause of pain/additional overhead on end consumers and library developers, for example:\r\n- in Scenery/Sciview where we have to [manually fix](https://github.com/scenerygraphics/scenery/blob/main/build.gradle.kts#L65-L96) the pom\r\n- in the incoming Gradle Platform I have to [manually hardcode](https://github.com/scijava/pom-scijava/blob/2653c2cd723c2466d6a0ccf89811ca8f96453bed/gradle/platform/build.gradle.kts#L24) a list of the runtime dependencies to later on setup a runtime constraints for those, instead of relying on some sort of \"runtime classifier schema\"\r\n\r\nThis attempt is a chance to fix also some other issues which are somehow (strictly) related, hopefully once and for all, before the new Foreign Function API transition/JNI future limitations take over.\r\n\r\nActually all of this goes beyond the scope of `native-lib-loader`, but there isn't really a right place to discuss about all of these thematics, so I'd just over-exploit the \"Issues\" space here as a placeholder.\r\n\r\nLet me write down some of the ideas we came with, the goal is to reach a broader audience for further feedbacks, improvements, etc..\r\n\r\nThis might be interesting for some other people outside this repo other than @ctrueden (and @bmarwell?), such as @jjohannes and @Spasi\r\n\r\n### One artifact for each supported \"`OS`_`Arch`\"\r\n\r\nFirst of all, natives should be published for each OS/Arch combination, in order to avoid pulling in dependencies thus downloading useless files which are not meant in any way for the given platform, just polluting the consumer classpath, saving space, bandwidth and time on scale.\r\n\r\nThe good new is that most of libraries nowadays already follow this path, but some of them (like [`jinput`](https://repo1.maven.org/maven2/net/java/jinput/jinput/2.0.10/)), unfortunately, don't. We could help them by providing a PR ourselves or, in the worst cases, re-publishing the artifact ourselves on scijava (or central by new GAVs)? I don't know\r\n\r\n### Using the os-maven-plugin normalized os and arch values\r\n\r\nYou can see them as `enum`s [here](https://github.com/elect86/native-support/blob/master/plugin/src/main/kotlin/org/nativeSupport/enums.kt), they are copy/pasted from the [os-maven-plugin](https://github.com/trustin/os-maven-plugin/blob/master/src/main/java/kr/motd/maven/os/Detector.java#L150)\r\n\r\nGradle has already something, but it's somehow [limited](https://gist.github.com/elect86/b1f6826a4d799f989f3f72c223a6e754). They also use `macos` for `MACOS`, to say\r\n\r\n### Publishing using the [Gradle Metadata rich format](https://docs.gradle.org/current/userguide/variant_model.html#understanding-variant-selection)\r\n\r\nGradle does this natively, of course, but a Gradle plugin will make the creation of those variants even easier\r\n\r\nAnd the [`gradle-module-metadata-maven-plugin`](https://github.com/jjohannes/gradle-module-metadata-maven-plugin?tab=readme-ov-file) will produce the Gradle metadata for library developers using Maven.\r\n\r\nThese library developers using Maven and targetting other Maven consumers should declare the natives dependency in their pom using placeholders for `OS` and `Arch`.\r\nIn the Scijava ecosystem this is already done today in some places, such [here](https://github.com/flimlib/flimj-ops/blob/master/pom.xml#L138C18-L138C44)\r\nWe should come up with some convention for the classifier, something like `natives-$os-$arch` could be an idea. Lwjgl [does already](https://repo1.maven.org/maven2/org/lwjgl/lwjgl/3.3.3/) something like that, although for x64 classifiers it simply shorten to `natives-$os`.\r\n\r\n### Extracting and caching natives\r\n\r\nNatives will be extracted into a directory following:\r\n- [XDG conventions](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html), so under the user home (like `~/.cache/native-lib-loader`)\r\n- [Gradle dependency cache](https://docs.gradle.org/current/userguide/dependency_resolution.html#sec:dependency_cache) GAVH (\"`gropId`/`artifactId`/`version`/`hashSha1`\") schema, it's important to take the hashing in account, as according to the [Gradle docs](https://docs.gradle.org/current/userguide/dependency_resolution.html#sub:cache_checksum_storage):\r\n\u003e It is possible for different repositories to provide a different binary artifact in response to the same artifact identifier. This is often the case with Maven SNAPSHOT artifacts, but can also be true for any artifact which is republished without changing its identifier. By caching artifacts based on their SHA1 checksum, Gradle is able to maintain multiple versions of the same artifact. This means that when resolving against one repository Gradle will never overwrite the cached artifact file from a different repository. This is done without requiring a separate artifact file store per repository.\r\n\r\n### Consuming the natives\r\n\r\nGradle handles `.module` file natively and will properly resolve them, no work needed there, the consumer has to just set the os and arch attributes to find the right natives under the hood. A plugin could also help by setting these values automatically, from the running machine underneath.\r\nScijava already does [something similar](https://github.com/flimlib/flimj-ops/blob/efd6d84ea67652b0ff1559a36cb7c610d3773e5b/pom.xml#L138) with `scijava.natives.classifier` \u0026 company. And corresponding Maven plugin (or whatsoever) might also provide the same automatic setup underneath\r\n\r\n### Loading the natives in runtime\r\n\r\nA `NativeLoader2` (or whatsoever) will read all the underlying native libraries from the given GAVH (\"`gropId`/`artifactId`/`version`/`hashSha1`\") coordinate, extracting them if they weren't already cached before, and load them downstream safely respecting the [JNI restriction](https://docs.oracle.com/javase/6/docs/technotes/guides/jni/jni-12.html#libmanage)\r\n\u003e The same JNI native library cannot be loaded into more than one class loader.\r\n\r\nThis means that classloader must match with the classloader of the class specifying the native methods.\r\nThis is achievable by the i-th class by passing down to `NativeLoader2` the reference to `System::load`, like Lwjgl is already [doing](https://github.com/LWJGL/lwjgl3/blob/master/modules/lwjgl/opengl/src/main/java/org/lwjgl/opengl/GL.java#L80) since ages\r\n\r\nAlso, we should prefer `System::load` to `System::loadLibrary`, since as it's noted [here](https://stackoverflow.com/questions/7016391/difference-between-system-load-and-system-loadlibrary-in-java#comment127547281_7016496)\r\n\r\n\u003e The drawback of loadLibrary() is so that it returns the confusing error message \"java.lang.UnsatisfiedLinkError: myLib (Not found in java.library.path)\" even if it is found, but could not be loaded due to other reasons. In such case calling load()/loadLibrary() with the absolute path shows additional output like \"rtld: Symbol myFunc was referenced ... but a runtime definition was not found.\" which is hidden by loadLibrary() with the library basename as argument. That is the best way is to write own method which iterates through java.library.path and calls load() per item.\r\n\r\nThis could solve issues such as [this one](https://github.com/ikvmnet/ikvm/issues/448)\r\n\r\nAnd/or we may use JNA to get dependency libraries properly added as well, as noted [here](https://stackoverflow.com/a/10138434/1047713). Some field in `META-INF/MANIFEST` might serve good for this purpose\r\n\r\nHowever, the default strategy should be to load all the native present in the given artifact, in case there are more than one\r\n\r\nLooking forwards for feedbacks :)","author":{"url":"https://github.com/elect86","@type":"Person","name":"elect86"},"datePublished":"2024-04-22T09:41:00.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/50/native-lib-loader/issues/50"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:8cb9f089-2546-3cc6-59af-d9b852c3269b
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idB336:2C5AFC:266C7F1:360BBEC:6969229D
html-safe-nonce035f6b7dabb5df69335995ef607f0886d40e7957f9dbf8a9ff1f2dd640846404
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMzM2OjJDNUFGQzoyNjZDN0YxOjM2MEJCRUM6Njk2OTIyOUQiLCJ2aXNpdG9yX2lkIjoiMjExMTE0NjE2MDU2NTA2ODQ0NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac5d1326af4a21898755003af5fcddf6397f8c38983ce3f0e1e405e5862a069217
hovercard-subject-tagissue:2256071205
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/scijava/native-lib-loader/50/issue_layout
twitter:imagehttps://opengraph.githubassets.com/8e9bef82efdbcd4f1cc544993bdd1c3df1b1c171092852820799df5d0d94d378/scijava/native-lib-loader/issues/50
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/8e9bef82efdbcd4f1cc544993bdd1c3df1b1c171092852820799df5d0d94d378/scijava/native-lib-loader/issues/50
og:image:altHello folks, I/we are trying to reboot the this library, the idea is to unify a lot of different leaf/sparse conventions all together for handling natives for the whole cycle, from the producer pub...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameelect86
hostnamegithub.com
expected-hostnamegithub.com
None54182691a21263b584d2e600b758e081b0ff1d10ffc0d2eefa51cf754b43b51d
turbo-cache-controlno-preview
go-importgithub.com/scijava/native-lib-loader git https://github.com/scijava/native-lib-loader.git
octolytics-dimension-user_id1262770
octolytics-dimension-user_loginscijava
octolytics-dimension-repository_id3805074
octolytics-dimension-repository_nwoscijava/native-lib-loader
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id3805074
octolytics-dimension-repository_network_root_nwoscijava/native-lib-loader
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
released69ac0477df0f87da03b8b06cebd187012d7a930
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/scijava/native-lib-loader/issues/50#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fscijava%2Fnative-lib-loader%2Fissues%2F50
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fscijava%2Fnative-lib-loader%2Fissues%2F50
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=scijava%2Fnative-lib-loader
Reloadhttps://github.com/scijava/native-lib-loader/issues/50
Reloadhttps://github.com/scijava/native-lib-loader/issues/50
Reloadhttps://github.com/scijava/native-lib-loader/issues/50
scijava https://github.com/scijava
native-lib-loaderhttps://github.com/scijava/native-lib-loader
Notifications https://github.com/login?return_to=%2Fscijava%2Fnative-lib-loader
Fork 43 https://github.com/login?return_to=%2Fscijava%2Fnative-lib-loader
Star 215 https://github.com/login?return_to=%2Fscijava%2Fnative-lib-loader
Code https://github.com/scijava/native-lib-loader
Issues 8 https://github.com/scijava/native-lib-loader/issues
Pull requests 1 https://github.com/scijava/native-lib-loader/pulls
Actions https://github.com/scijava/native-lib-loader/actions
Projects 0 https://github.com/scijava/native-lib-loader/projects
Wiki https://github.com/scijava/native-lib-loader/wiki
Security Uh oh! There was an error while loading. Please reload this page. https://github.com/scijava/native-lib-loader/security
Please reload this pagehttps://github.com/scijava/native-lib-loader/issues/50
Insights https://github.com/scijava/native-lib-loader/pulse
Code https://github.com/scijava/native-lib-loader
Issues https://github.com/scijava/native-lib-loader/issues
Pull requests https://github.com/scijava/native-lib-loader/pulls
Actions https://github.com/scijava/native-lib-loader/actions
Projects https://github.com/scijava/native-lib-loader/projects
Wiki https://github.com/scijava/native-lib-loader/wiki
Security https://github.com/scijava/native-lib-loader/security
Insights https://github.com/scijava/native-lib-loader/pulse
New issuehttps://github.com/login?return_to=https://github.com/scijava/native-lib-loader/issues/50
New issuehttps://github.com/login?return_to=https://github.com/scijava/native-lib-loader/issues/50
Library reboot and much morehttps://github.com/scijava/native-lib-loader/issues/50#top
https://github.com/elect86
https://github.com/elect86
elect86https://github.com/elect86
on Apr 22, 2024https://github.com/scijava/native-lib-loader/issues/50#issue-2256071205
manually fixhttps://github.com/scenerygraphics/scenery/blob/main/build.gradle.kts#L65-L96
manually hardcodehttps://github.com/scijava/pom-scijava/blob/2653c2cd723c2466d6a0ccf89811ca8f96453bed/gradle/platform/build.gradle.kts#L24
@ctruedenhttps://github.com/ctrueden
@bmarwellhttps://github.com/bmarwell
@jjohanneshttps://github.com/jjohannes
@Spasihttps://github.com/Spasi
jinputhttps://repo1.maven.org/maven2/net/java/jinput/jinput/2.0.10/
herehttps://github.com/elect86/native-support/blob/master/plugin/src/main/kotlin/org/nativeSupport/enums.kt
os-maven-pluginhttps://github.com/trustin/os-maven-plugin/blob/master/src/main/java/kr/motd/maven/os/Detector.java#L150
limitedhttps://gist.github.com/elect86/b1f6826a4d799f989f3f72c223a6e754
Gradle Metadata rich formathttps://docs.gradle.org/current/userguide/variant_model.html#understanding-variant-selection
gradle-module-metadata-maven-pluginhttps://github.com/jjohannes/gradle-module-metadata-maven-plugin?tab=readme-ov-file
herehttps://github.com/flimlib/flimj-ops/blob/master/pom.xml#L138C18-L138C44
does alreadyhttps://repo1.maven.org/maven2/org/lwjgl/lwjgl/3.3.3/
XDG conventionshttps://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
Gradle dependency cachehttps://docs.gradle.org/current/userguide/dependency_resolution.html#sec:dependency_cache
Gradle docshttps://docs.gradle.org/current/userguide/dependency_resolution.html#sub:cache_checksum_storage
something similarhttps://github.com/flimlib/flimj-ops/blob/efd6d84ea67652b0ff1559a36cb7c610d3773e5b/pom.xml#L138
JNI restrictionhttps://docs.oracle.com/javase/6/docs/technotes/guides/jni/jni-12.html#libmanage
doinghttps://github.com/LWJGL/lwjgl3/blob/master/modules/lwjgl/opengl/src/main/java/org/lwjgl/opengl/GL.java#L80
herehttps://stackoverflow.com/questions/7016391/difference-between-system-load-and-system-loadlibrary-in-java#comment127547281_7016496
this onehttps://github.com/ikvmnet/ikvm/issues/448
herehttps://stackoverflow.com/a/10138434/1047713
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.