> Currently, the hotspot compiler (as in ciField) trusts final fields in hidden 
> classes, record classes, and selected jdk packages. Some classes in the JDK 
> wish to be trusted, but they cannot apply package-wide opt-in due to other 
> legacy classes in the package, such as java.util.
> 
> They currently can use `@Stable` as a workaround, but this is fragile because 
> a stable final field may hold a trusted null, zero, or false value, which is 
> currently treated as non-constant by ciField.
> 
> We should add an annotation to opt-in for a whole class, mainly for legacy 
> packages. This would benefit greatly some of our classes already using a lot 
> of Stable, such as java.util.Optional, whose empty instance is now 
> constant-foldable, as demonstrated in a new IR test.
> 
> Paging @minborg who requested Optional folding for review.
> 
> I think we can remove redundant Stable in a few other java.util classes after 
> this patch is integrated. I plan to do that in subsequent patches.

Chen Liang has updated the pull request with a new target base due to a merge 
or a rebase. The incremental webrev excludes the unrelated changes brought in 
by the merge/rebase. The pull request contains 11 additional commits since the 
last revision:

 - Jorn review
 - Merge branch 'master' of https://github.com/openjdk/jdk into 
feature/class-final-trusting
 - bracket styles
 - Doc tweaks
 - Essay
 - Spurious change
 - Merge branch 'master' of https://github.com/openjdk/jdk into 
feature/class-final-trusting
 - Issue number and test update
 - Fixed optional and unit test
 - Merge branch 'master' of https://github.com/openjdk/jdk into 
feature/class-final-trusting
 - ... and 1 more: https://git.openjdk.org/jdk/compare/383203c0...b20b7f5b

-------------

Changes:
  - all: https://git.openjdk.org/jdk/pull/28540/files
  - new: https://git.openjdk.org/jdk/pull/28540/files/d353bdbe..b20b7f5b

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=28540&range=04
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=28540&range=03-04

  Stats: 38514 lines in 729 files changed: 24382 ins; 11087 del; 3045 mod
  Patch: https://git.openjdk.org/jdk/pull/28540.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/28540/head:pull/28540

PR: https://git.openjdk.org/jdk/pull/28540

Reply via email to