logoalt Hacker News

cogman10yesterday at 7:56 PM3 repliesview on HN

This is a great change that will undoubtedly cause a lot of headaches.

There's a number of libraries (particularly around serialization/marshaling) which will end up mutating `final` fields. In fact, this is a trick I've pulled once or twice in my own code for "reasons" (generally needing to modify behavior of a library because it was deficient).

I suspect this will be one of those things that ends up requiring java devs everywhere to bump up the versions of the libraries they use.


Replies

debugnikyesterday at 8:48 PM

That's a separate series of JEPs known as "final means final", also starting to land nowadays.

https://openjdk.org/jeps/500

show 1 reply
kasperniyesterday at 8:01 PM

Strict Field Initialization is opt-in. A flag needs to be set in the classfile in order to enable it. So should not effect any existing code.

show 1 reply
well_ackshuallyyesterday at 10:47 PM

>particularly around serialization/marshaling

The solution being to drop those dogshit reflection based libraries as everyone should have done 10 years ago when codegen became more common.

Looking at you, Gson.

show 1 reply