RFR: 8353835: Implement JEP 500: Prepare to Make Final Mean Final
Alan Bateman
alanb at openjdk.org
Mon Sep 22 08:41:39 UTC 2025
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 fatal error when a mutating a final field with JNI, and -Xlog:jni=debug can help identity when JNI code mutates finals. For now, JNI code is allowed to set the "write-protected" fields System.in/out/err, 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
-------------
Commit messages:
- Merge branch 'master' into JDK-8353835
- Test cleanup
- More improvements
- Update for jtreg 8
- Merge branch 'master' into JDK-8353835
- Cleanup
- Merge branch 'master' into JDK-8353835
- TestDefaultConfigurations failing
- Test failures
- Merge branch 'master' into JDK-8353835
- ... and 6 more: https://git.openjdk.org/jdk/compare/682fd784...bfad2bbe
Changes: https://git.openjdk.org/jdk/pull/25115/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=25115&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8353835
Stats: 4547 lines in 61 files changed: 4387 ins; 43 del; 117 mod
Patch: https://git.openjdk.org/jdk/pull/25115.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/25115/head:pull/25115
PR: https://git.openjdk.org/jdk/pull/25115
More information about the core-libs-dev
mailing list