Apache Fory Serialization 1.2.0: JDK 25 support without sun.misc.Unsafe

chaokunyang1 pts1 comments

Release v1.2.0 · apache/fory · GitHub

//releases/show" data-turbo-transient="true" />

Skip to content

Search or jump to...

Search code, repositories, users, issues, pull requests...

-->

Search

Clear

Search syntax tips

Provide feedback

--><br>We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Cancel

Submit feedback

Saved searches

Use saved searches to filter your results more quickly

-->

Name

Query

To see all available qualifiers, see our documentation.

Cancel

Create saved search

Sign in

//releases/show;ref_cta:Sign up;ref_loc:header logged out"}"<br>Sign up

Appearance settings

Resetting focus

You signed in with another tab or window. Reload to refresh your session.<br>You signed out in another tab or window. Reload to refresh your session.<br>You switched accounts on another tab or window. Reload to refresh your session.

Dismiss alert

{{ message }}

apache

fory

Public

Notifications<br>You must be signed in to change notification settings

Fork<br>424

Star<br>4.4k

v1.2.0

Latest

Latest

Compare

Choose a tag to compare

Sorry, something went wrong.

Filter

Loading

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

No results found

View all tags

chaokunyang

released this

16 Jun 12:22

&middot;

2 commits

to main<br>since this release

v1.2.0

097966b

Highlights

Expanded generated gRPC support across Go, Rust, Kotlin, Scala, C#, and JavaScript, including Node.js and browser gRPC-Web support for JavaScript.

Improved cross-language compatibility with refined register-by-name APIs, compatible scalar read conversions, and default compatible mode for native serialization.

Strengthened Java platform support by adding Java 9/16 module-info generation and removing sun.misc.Unsafe usage for JDK 25.

Improved runtime safety and robustness with additional read checks, deflater leak fixes, and safer serializer/type-info error handling.

Optimized compatible-mode and row-format performance through faster compatible reads, compact row layout caching, and inlined custom-codec dispatch.

Enhanced compiler output quality across Rust, C++, and service generation with better identifier escaping, name-collision handling, nested container reference handling, and map code generation.

Java 25+ Without sun.misc.Unsafe

JDK 25 continues the platform shift away from sun.misc.Unsafe. Fory 1.2.0

adds a Java 25 multi-release runtime path so applications can run on JDK 25+

without resolving sun.misc.Unsafe from Fory's active class graph.

Older JDKs keep the existing fast paths. On JDK 25+, Fory uses replacement

classes backed by supported JVM mechanisms such as VarHandle, MethodHandle,

arrays, and ByteBuffer. Classes that previously depended on constructor

bypassing should provide an accessible no-arg constructor, use records, or

register a custom serializer.

Compatible Scalar Field Reads

Compatible mode already allows readers and writers to add, remove, and reorder

fields. Fory 1.2.0 extends that model to selected scalar type changes: when a

matched top-level field changes between boolean, string, numeric, and decimal

types, the reader can deserialize the value if the conversion is lossless.

Examples include reading "123" as an integer field, reading 1 or 0 as a

boolean field, reading booleans as 1/0, reading numbers or decimals as

canonical strings, and widening or narrowing numeric values only when no range

or precision is lost. Invalid strings, out-of-range values, lossy float/integer

conversions, and reference-tracked scalar type changes fail during

deserialization. The conversion applies to matched compatible fields, not to

root values or collection elements.

The examples below show Rust and Java using an int64 writer field and a

String reader field. The same compatible scalar field conversion is supported

across Fory's compatible-mode runtimes: Java, Python, Rust, C++, Go, C#, Swift,

Dart, JavaScript/TypeScript, Kotlin, and Scala. Compatible mode is enabled by

default in the Java and Python runtimes for both xlang and native serialization.

Rust example:

("example.Metric")?;

let mut reader = Fory::builder().xlang(true).compatible(true).build();<br>reader.register_by_name::("example.Metric")?;

let bytes = writer.serialize(&MetricV1 { value: 42 })?;<br>let value: MetricV2 = reader.deserialize(&bytes)?;<br>assert_eq!(value.value, "42");">use fory::{Fory, ForyStruct};

#[derive(ForyStruct)]<br>struct MetricV1 {<br>value: i64,

#[derive(ForyStruct)]<br>struct MetricV2 {<br>value: String,

let mut writer = Fory::builder().xlang(true).compatible(true).build();<br>writer.register_by_name::MetricV1>("example.Metric")?;

let mut reader = Fory::builder().xlang(true).compatible(true).build();<br>reader.register_by_name::MetricV2>("example.Metric")?;

let bytes = writer.serialize(&MetricV1 { value: 42 })?;<br>let value: MetricV2 = reader.deserialize(&bytes)?;<br>assert_eq!(value.value, "42");

Java example:

public...

fory compatible value java reader true

Related Articles