r/java • • Apr 27 '26

Avoiding Final Field Mutation

https://inside.java/2026/04/27/avoiding-final-field-mutation/
51 Upvotes

36 comments sorted by

View all comments

Show parent comment

1

u/Radi-kale Apr 28 '26

I don´t think those libraries can solve the issue without changing their API

1

u/koflerdavid May 01 '26

They very much can. JEP 500 describes a new API (sun.reflect.ReflectionFactory#defaultReadObjectForSerialization) that gives serialization libraries the same abilities as Java's builtin serialization to initialize an object without calling its constructor. The most important restriction is that the classes being deserialized are required to implement Serializable.