Title: Java 25, the Foreign Function & Memory API and removal of Unsafe · Issue #259 · lmdbjava/lmdbjava · GitHub
Open Graph Title: Java 25, the Foreign Function & Memory API and removal of Unsafe · Issue #259 · lmdbjava/lmdbjava
X Title: Java 25, the Foreign Function & Memory API and removal of Unsafe · Issue #259 · lmdbjava/lmdbjava
Description: @stroomdev66 and I (@at055612) have recently been added as committers on this project to help out @benalexau, having been long time users of LmdbJava and occasional contributors. We actively use LmdbJava in a number of different use case...
Open Graph Description: @stroomdev66 and I (@at055612) have recently been added as committers on this project to help out @benalexau, having been long time users of LmdbJava and occasional contributors. We actively use Lm...
X Description: @stroomdev66 and I (@at055612) have recently been added as committers on this project to help out @benalexau, having been long time users of LmdbJava and occasional contributors. We actively use Lm...
Opengraph URL: https://github.com/lmdbjava/lmdbjava/issues/259
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Java 25, the Foreign Function \u0026 Memory API and removal of Unsafe","articleBody":"@stroomdev66 and I (@at055612) have recently been added as committers on this project to help out @benalexau, having been long time users of LmdbJava and occasional contributors.\nWe actively use LmdbJava in a number of different use cases in our OSS project and are very grateful to @benalexau, @krisskross and all the other contributors for a great library.\n\nNow that Java 25 and its new Foreign Function and Memory API are in general availability, it seems sensible to incorporate them into LmdbJava.\nThis has been a long anticipated change (see #42).\nWe are therefore keen to make changes to LmdbJava to incorporate the FFM API and remove the use of `Unsafe`.\n@stroomdev66 has done some initial experimentation with replacing jnr-ffi with the new FFM API.\n\nSuch changes need to be done in a way that does not cause too much pain for the LmdbJava user community.\nWe have had some initial exploratory conversations with @benalexau about the way forward and this is a current rough plan.\n\n---\n\n# LmdbJava v1.x\n\n* Maintain the current Java compile target of Java 8.\n* Address the two outstanding PRs:\n * #250 - This one is mine and needs to be finished to address comparator issues introduced in 0.9.0.\n It will mean the removal of `MDB_UNSIGNEDKEY` that was added in 0.9.1 to partially address 0.9.0.\n * #255\n* Uplift any existing dependencies, including LMDB.\n\nUsers that are not in a position to move to Java 25 can continue to use v1.x with no change.\n\n\n# LmdbJava v2.x\n\n* Change the Java compile target to Java 25.\n* Change the internal LmdbJava code to use the FFM API for interaction with LMDB.\n* Change `Env` to create and hold on to an `Arena` instance for its life.\n This will be used for creating MemorySegments internally.\n* Change the internal LmdbJava code to use MemorySegments when interacting with LMDB.\n* Change the existing BufferProxy implementations to map the buffers to MemorySegments.\n* Add a new MemorySegmentProxy class so that client code can fully exploit MemorySegment, e.g. `Env\u003cMemorySegment\u003e`.\n* Remove any use of Unsafe.\n\nThis seems like the best way to use the FFM API without causing a lot of breaking change for users of LmdbJava.\nIt may come at the cost of some performance penalty due to mapping between buffer implementations and MemorySegment.\nThere may also be performance differences between MemorySegment and Unsafe buffer access.\n\nThis work is currently in progress on this branch:\nhttps://github.com/lmdbjava/lmdbjava/tree/java-foreign-function-and-memory-api\n\nand there is a draft PR for the work here #258.\n\nUsers that can migrate to Java 25, but have a lot of existing code built around Netty/Agrona/DirectByteBuffer can use this with hopefully no or minimal change.\n\n\n# LmdbJava v3.x\n\n* Include all of the v2.x work.\n* Remove the generic `\u003cT\u003e` type from `Env`/`Dbi`/`Txn`, etc.\n* Change the LmdbJava API to exclusively use `MemorySegment` rather than `T`.\n* Remove the netty and agrona dependencies.\n* Remove BufferProxy and all its implementations.\n\nWe think that ultimately MemorySegment is the natural replacement of the various buffer implementations.\nIt offers a much richer API for working with ranges of memory.\nTherefore it seems sensible for MemorySegment to be the only mechanism for passing data in/out of LMDB.\n\nWe assume that for people that use Netty and Agrona in their projects, that Netty/Agrona will in time improve their libraries to integrate with MemorySegments so that LmdbJava users can map back/forth themselves.\n\nRemoving the various buffer implementations will make the LmdbJava code simpler and make it easier for the LmdbJava maintainers to maintain the project and support users' issues.\n\nUsers who can migrate to Java 25 and have little or no legacy buffer based code can move to this version.\n\n---\n\nWe welcome any comments or suggestions that people have on the Java25/FFM/Unsafe changes and/or the general direction of LmdbJava development.\n","author":{"url":"https://github.com/at055612","@type":"Person","name":"at055612"},"datePublished":"2025-10-24T13:02:35.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":15},"url":"https://github.com/259/lmdbjava/issues/259"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:0c70bb5d-823a-246e-59ae-720bc7e307d9 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B0E2:6CA27:1D9F568:27FCCC7:69707B37 |
| html-safe-nonce | e1b55776bc281148e91be8e5ee7442549d1b16f463653b45e629f922402649e5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMEUyOjZDQTI3OjFEOUY1Njg6MjdGQ0NDNzo2OTcwN0IzNyIsInZpc2l0b3JfaWQiOiIyMTE4OTAwNDIzMzcwNzY3MTU5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 1948a98184919abb363630d4a07103fb7fcebd0c0b6560d7764b200229316df7 |
| hovercard-subject-tag | issue:3549401788 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/lmdbjava/lmdbjava/259/issue_layout |
| twitter:image | https://opengraph.githubassets.com/9f6e5b45a7e6ec190b55f36e0637e1094421152ca67c85275161e96d248c7182/lmdbjava/lmdbjava/issues/259 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/9f6e5b45a7e6ec190b55f36e0637e1094421152ca67c85275161e96d248c7182/lmdbjava/lmdbjava/issues/259 |
| og:image:alt | @stroomdev66 and I (@at055612) have recently been added as committers on this project to help out @benalexau, having been long time users of LmdbJava and occasional contributors. We actively use Lm... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | at055612 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9920a62ba22d06470388e2904804fb7e5ec51c9e35f81784e9191394c74b2bd2 |
| turbo-cache-control | no-preview |
| go-import | github.com/lmdbjava/lmdbjava git https://github.com/lmdbjava/lmdbjava.git |
| octolytics-dimension-user_id | 19765602 |
| octolytics-dimension-user_login | lmdbjava |
| octolytics-dimension-repository_id | 60480511 |
| octolytics-dimension-repository_nwo | lmdbjava/lmdbjava |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 60480511 |
| octolytics-dimension-repository_network_root_nwo | lmdbjava/lmdbjava |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 7d6181066430cc06553c8396ca201e194ae33cb9 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width