JEP draft: Prepare to make final mean final
Published on: 2025-05-21 00:35:51
Summary
Issue warnings about uses of deep reflection to mutate final fields. The warnings aim to prepare developers for a future release that ensures integrity by default by restricting final field mutation; this makes Java programs safer and potentially faster. Application developers can avoid both current warnings and future restrictions by selectively enabling the ability to mutate final fields where essential.
Goals
Prepare the Java ecosystem for a future release that, by default, disallows the mutation of final fields by deep reflection. As of that release, application developers will have to explicitly enable the capability to do so at startup.
fields by deep reflection. As of that release, application developers will have to explicitly enable the capability to do so at startup. Align final fields in normal classes with the implicitly declared fields of record classes, which cannot be mutated by deep reflection.
fields in normal classes with the implicitly declared fields of
... Read full article.