On Wed, 8 Apr 2026 21:16:15 GMT, Chris Plummer <[email protected]> wrote:

>> com/sun/jdi/EATests.java synchronizes on an Integer instance. Although this 
>> currently works, it is discouraged. See the following doc on value based 
>> classes:
>> 
>> https://docs.oracle.com/en/java/javase/24/docs/api/java.base/java/lang/doc-files/ValueBased.html
>> 
>> "Synchronization on instances of value-based classes is strongly 
>> discouraged, because the programmer cannot guarantee exclusive ownership of 
>> the associated monitor.
>> 
>> Identity-related behavior of value-based classes may change in a future 
>> release. For example, synchronization may fail."
>> 
>> That second part is realized by Valhalla. The synchronization fails with:
>> 
>> `java.lang.IdentityException: Cannot synchronize on an instance of value 
>> class java.lang.Integer`
>> 
>> Valhalla CR [JDK-8372831](https://bugs.openjdk.org/browse/JDK-8372831) 
>> covers that failure, but I thought it best to address this in mainline first.
>> 
>> Tested with all of CI tier1, tier2 svc, and tier5 svc.
>
> Chris Plummer has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   remove locking on Integer

>From the perspective of a Valhalla VM developer, regarding 
>https://github.com/openjdk/jdk/pull/30560#discussion_r3054520780, I think (1) 
>is the way to go, and we already have the code ready! (2) is also a good 
>solution I'd be in favour of. I don't think it is wise to lose preview 
>coverage as suggested by (4), and (3) would inflate the mainline diff when JEP 
>401 is under review (some might say at almost 200k additions this does not 
>matter, I think if we can avoid more diffs we should).

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

Marked as reviewed by phubner (Committer).

PR Review: https://git.openjdk.org/jdk/pull/30560#pullrequestreview-4088379511

Reply via email to