Commit 075421f
authored
feat(java): remove sun.misc.Unsafe for jdk25+ (#3702)
## Why?
JDK25+ removes the remaining viable `sun.misc.Unsafe` paths Fory used
for Java object creation, field access, string internals, and memory
operations. This PR makes the Java runtime continue to support modern
JDKs while preserving the existing JDK8-24, Android, GraalVM,
native-mode, and xlang behavior where applicable.
## What does this PR do?
- Builds `fory-core` as a multi-release jar with JDK25-specific classes
and module metadata, while keeping the root implementation for JDK8-24.
- Replaces the JDK25+ runtime paths for field access, object
instantiation, string internals, memory access, and generated
serializers with trusted lookup, VarHandle, ReflectionFactory, and other
non-Unsafe owners.
- Updates Java serializers, codegen, copy paths, collection/map
serializers, object stream handling, and default-value support to use
the new accessor and instantiator ownership model.
- Extends CI and integration coverage for JDK25/JDK26, JPMS zero-Unsafe
runs, multi-release jar verification, GraalVM packaging, and cross-JDK
compatibility expectations.
- Updates Java, Kotlin, Scala, and top-level docs for JDK25+ setup,
including the required `java.base/java.lang.invoke` open for classpath
and module-path users.
- Adds Java25 benchmark modules and MR-JAR benchmark verification for
direct memory and direct-to-heap copy paths.
## Related issues
Closes #3729
Closes #2090
Closes #2606
## AI Contribution Checklist
- [ ] Substantial AI assistance was used in this PR: `yes` / `no`
- [ ] If `yes`, I included a completed [AI Contribution
Checklist](https://github.com/apache/fory/blob/main/AI_POLICY.md#9-contributor-checklist-for-ai-assisted-prs)
in this PR description and the required `AI Usage Disclosure`.
- [ ] If `yes`, my PR description includes the required `ai_review`
summary and screenshot evidence of the final clean AI review results
from both fresh reviewers on the current PR diff or current HEAD after
the latest code changes.
## Does this PR introduce any user-facing change?
Yes. Java users on JDK25+ must open `java.base/java.lang.invoke` to
Fory:
- Classpath: `--add-opens=java.base/java.lang.invoke=ALL-UNNAMED`
- Module path:
`--add-opens=java.base/java.lang.invoke=org.apache.fory.core`
No binary protocol compatibility change is intended.
- [ ] Does this PR introduce any public API change?
- [ ] Does this PR introduce any binary protocol compatibility change?
## Benchmark
This PR adds Java25 benchmark coverage under `benchmarks/java25` and a
benchmark MR-JAR check. No benchmark result table is included here.1 parent 33b0d6e commit 075421f
215 files changed
Lines changed: 17706 additions & 4480 deletions
File tree
- .agents/languages
- .github/workflows
- benchmarks
- java25
- src/main/java/org/apache/fory/benchmark/java25
- java
- src/main
- java17/org/apache/fory/benchmark
- java/org/apache/fory/benchmark
- ci
- tasks
- docs/guide
- java
- kotlin
- scala
- integration_tests
- android_tests/src/main/java/org/apache/fory/android
- graalvm_tests
- src/main/java/org/apache/fory/graalvm
- jdk_compatibility_tests
- src/test/java/org/apache/fory/integration_tests
- jpms_tests
- src
- main/java
- org/apache/fory/integration_tests
- model
- publicserializer
- test/java/org/apache/fory/integration_tests
- java
- fory-core
- src
- main
- java16
- java25
- org/apache/fory
- builder
- memory
- platform/internal
- reflect
- serializer
- java9
- java/org/apache/fory
- builder
- codegen
- memory
- meta
- platform
- internal
- reflect
- resolver
- serializer
- collection
- scala
- type
- util
- function
- record
- unsafe
- resources/META-INF
- native-image/org.apache.fory/fory-core
- test/java/org/apache/fory
- builder
- codegen
- pkgprivate
- collection
- config
- memory
- meta
- platform/internal
- reflect
- resolver
- serializer
- collection
- otherpkg
- util
- fory-extensions/src/main/java/org/apache/fory/extension/serializer
- fory-format
- src
- main/java/org/apache/fory/format
- row/binary
- writer
- vectorized
- test/java/org/apache/fory/format
- row/binary
- vectorized
- fory-graalvm-feature/src/main/java/org/apache/fory/graalvm/feature
- fory-latest-jdk-tests/src/test/java/org/apache/fory/integration_tests
- fory-test-core/src/main/java/org/apache/fory/test/bean
- fory-testsuite
- src/test/java/org/apache/fory/test
- kotlin
- fory-kotlin-ksp/src
- main/kotlin/org/apache/fory/kotlin/ksp
- test/kotlin/org/apache/fory/kotlin/ksp
- fory-kotlin-tests
- src/main/kotlin/org/apache/fory/kotlin/xlang
- fory-kotlin/src
- main/kotlin/org/apache/fory/serializer/kotlin
- test/kotlin/org/apache/fory/serializer/kotlin
- scala
- src/main
- java/org/apache/fory/serializer/scala
- scala/org/apache/fory/serializer/scala
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
9 | 17 | | |
10 | 18 | | |
11 | 19 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
169 | 169 | | |
170 | 170 | | |
171 | 171 | | |
172 | | - | |
| 172 | + | |
173 | 173 | | |
174 | 174 | | |
175 | 175 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
36 | | - | |
| 35 | + | |
| 36 | + | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
| 43 | + | |
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
145 | 158 | | |
146 | 159 | | |
147 | 160 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
212 | 212 | | |
213 | 213 | | |
214 | 214 | | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | 215 | | |
223 | 216 | | |
224 | 217 | | |
| |||
236 | 229 | | |
237 | 230 | | |
238 | 231 | | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
239 | 362 | | |
240 | 363 | | |
241 | 364 | | |
| |||
266 | 389 | | |
267 | 390 | | |
268 | 391 | | |
| 392 | + | |
269 | 393 | | |
270 | 394 | | |
271 | 395 | | |
| |||
287 | 411 | | |
288 | 412 | | |
289 | 413 | | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
290 | 418 | | |
291 | 419 | | |
292 | 420 | | |
| |||
298 | 426 | | |
299 | 427 | | |
300 | 428 | | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
301 | 441 | | |
302 | 442 | | |
303 | 443 | | |
| |||
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
99 | 100 | | |
100 | 101 | | |
101 | 102 | | |
102 | | - | |
| 103 | + | |
103 | 104 | | |
104 | 105 | | |
105 | 106 | | |
| |||
Lines changed: 2 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
22 | 21 | | |
23 | 22 | | |
24 | 23 | | |
| |||
405 | 404 | | |
406 | 405 | | |
407 | 406 | | |
408 | | - | |
409 | | - | |
410 | | - | |
411 | | - | |
412 | | - | |
413 | | - | |
| 407 | + | |
414 | 408 | | |
415 | 409 | | |
416 | | - | |
417 | | - | |
418 | | - | |
419 | | - | |
420 | | - | |
421 | | - | |
| 410 | + | |
422 | 411 | | |
423 | 412 | | |
424 | 413 | | |
| |||
0 commit comments