logoalt Hacker News

debugnikyesterday at 8:48 PM1 replyview on HN

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

https://openjdk.org/jeps/500


Replies

cogman10yesterday at 8:51 PM

I believe these 2 are effectively linked.

There's a jdk.internal API which will work as an escape hatch, but that does come with the need for non-compliant libraries to switch over to it. That safety hatch also only allows the setting of final fields once before observation (which is generally fine). So if your code is doing something more esoteric that sets a final field multiple times you will be SOL.

In any case, if you are using the sun.misc.Unsafe methods for setting final and private fields you'll need to update.