r/java • u/Shawn-Yang25 • Jun 16 '26
Apache Fory Serialization 1.2.0 released: JDK 25/26 support without sun.misc.Unsafe
https://github.com/apache/fory/releases/tag/v1.2.0
51
Upvotes
r/java • u/Shawn-Yang25 • Jun 16 '26
View all comments
Show parent comment
3
u/Shawn-Yang25 Jun 16 '26
Use constructor is better, the key obstacle is that jvm may not reserve constructor parameters unless with parameters compiler options, so it's hard to match constructor to field names. And for andriod r8, it even shuffle the code.
To use constructor for such cases, one must use annotation to annotate the constructor, so the framework can know how to match the fields into constructor parameter.
I acutally implemented this, but reverted it later because it's hard to enforce this for all classes. And it would be a huge breaking changes.
It's still a good direction to let users to use constructor, if the user can control all the classes which will be serialized.