RFR: 8356255: Add Stable Field Updaters to allow efficient lazy field evaluations [v4]

Per Minborg pminborg at openjdk.org
Wed May 7 13:55:10 UTC 2025


On Wed, 7 May 2025 11:54:09 GMT, David Beaumont <duke at openjdk.org> wrote:

>> Per Minborg has updated the pull request incrementally with two additional commits since the last revision:
>> 
>>  - Reformat
>>  - Revert changes in public classes
>
> test/jdk/java/lang/StableValue/StableFieldUpdaterExampleTest.java line 117:
> 
>> 115:         private static final ToIntFunction<LazyFoo> HASH_UPDATER =
>> 116:                 StableFieldUpdater.ofInt(LazyFoo.class, "hash",
>> 117:                         l -> Objects.hash(l.bar, l.baz), -1);
> 
> As someone unfamiliar with this, I'm given to ask "What's the -1 for?"
> 
> I *think* I can intuit that it's a value to be used *if* the hashcode actually ends up calculating zero (so any random bit pattern would (should?) be equally useful?
> 
> In example code if feels like this is not quite explaining itself enough to teach someone about its usage. For example (if it's what I think) it can't actually be passed as zero.

I've added some verbiage around this now. Let me know if it can be improved further.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25040#discussion_r2077688537


More information about the net-dev mailing list