RFR: 8353835: Implement JEP 500: Prepare to Make Final Mean Final [v11]
Viktor Klang
vklang at openjdk.org
Wed Nov 12 14:35:54 UTC 2025
On Tue, 11 Nov 2025 17:48:43 GMT, Alan Bateman <alanb at openjdk.org> wrote:
>> Implementation changes for [JEP 500: Prepare to Make Final Mean Final](https://openjdk.org/jeps/500).
>>
>> Field.set (and Lookup.unreflectSetter) are changed to allow/warn/debug/deny when mutating a final instance field. JFR event recorded if final field mutated. Spec updates to Field.set, Field.setAccessible and Module.addOpens to align with the proposal in the JEP.
>>
>> HotSpot is updated to add support for the new command line options. To aid diagnosability, -Xcheck:jni reports a warning and -Xlog:jni=debug logs a message to help identity JNI code that mutates finals. For now, JNI code is allowed to set the "write-protected" fields System.in/out/err without a warning, we can re-visit once we change the System.setIn/setOut/setErr methods to not use JNI (I prefer to keep this separate to this PR because there is a small startup regression to address when changing System.setXXX).
>>
>> There are many new tests. A small number of existing tests are changed to run /othervm as reflectively opening a package isn't sufficient. Changing the tests to /othervm means that jtreg will launch the agent with the command line options to open the package.
>>
>> Testing: tier1-6
>
> Alan Bateman has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 50 commits:
>
> - Remove dup end body tag
> - Change FinalFieldMutationEvent so that caller is top frame in stack trace
> - Merge branch 'master' into JDK-8353835
> - Review feedback: Add tests for setting internal properties, improve links in Mutation methods page
> - Merge branch 'master' into JDK-8353835
> - Merge branch 'master' into JDK-8353835
> - Fix typo in test comment
> - Merge branch 'master' into JDK-8353835
> - Merge branch 'master' into JDK-8353835
> - Suppress warnings from some tests
> - ... and 40 more: https://git.openjdk.org/jdk/compare/2902436f...b22947c7
src/java.base/share/man/java.md line 482:
> 480:
> 481: - `allow`: This mode allows illegal final field mutation in all modules,
> 482: without any warings.
Suggestion:
without any warnings.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25115#discussion_r2518551065
More information about the core-libs-dev
mailing list