JDK-8368961 : Remove redundant checks in ciField.cpp
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 26
  • Priority: P5
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2025-09-30
  • Updated: 2025-11-24
  • Resolved: 2025-11-17
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 26
26 b25Fixed
Related Reports
Causes :  
Duplicate :  
Description
In 2019, Jorn added that all `final` fields in classes that reside in the `java.lang` packages are trusted fields in the class `ciFields.cpp`. This would allow us to remove some of the previous checks as they are already covered by the package check. 

The package check is:       holder->is_in_package("java/lang"))

In addition, the untrusted fields in java.lang.System are all static fields. The special rule for java.lang.System is never useful because it has no untrusted instance field; furthermore, the problematic static fields are already checked before trust_final_non_static_fields is called.

So we should remove:
1. java_lang_System check
2. is_box_klass check
3. java_lang_String check
Comments
Changeset: df35412d Branch: master Author: Zihao Lin <linzihao1999@outlook.com> Committer: Tobias Hartmann <thartmann@openjdk.org> Date: 2025-11-17 11:49:01 +0000 URL: https://git.openjdk.org/jdk/commit/df35412db1d7e883148590e24d968cfe2f5c6bbc
17-11-2025

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/28191 Date: 2025-11-07 10:57:53 +0000
12-11-2025

The check for System is redundant - the 3 problematic fields are already filtered before trust_final_non_static_fields(ciInstanceKlass) is ever called. is_box_klass and java_lang_String checks can also be removed.
12-11-2025

[~pminborg] please link JBS issue (RFE) which added the code. And point which check in which method in `ciFields.cpp` you are talking about.
30-09-2025