On Fri, 19 Jun 2026 07:44:28 GMT, Jaikiran Pai <[email protected]> wrote:

> Can I please get a review of this change which proposes to improve the 
> exception message in `IllegalMonitorStateException` when it gets thrown for 
> value objects?
> 
> With this change, we now report the following exception message when value 
> objects are used to invoke `Object.wait()` and related methods:
> 
> 
> jshell> o.wait()
> |  Exception java.lang.IllegalMonitorStateException: current thread is not 
> owner
> |        at Object.wait0 (Native Method)
> |        at Object.wait (Object.java:433)
> |        at Object.wait (Object.java:387)
> |        at (#2:1)
> 
> There were some thoughts about using an exception message of the form 
> `Exception java.lang.IllegalMonitorStateException: object's type 
> java.lang.Integer is not an identity class`. But since value objects cannot 
> be synchronized upon, we decided it would be fine (and accurate) to reuse the 
> same "current thread is not owner" exception message that we use for identity 
> objects.
> 
> Given the nature of this change, I haven't added any new jtreg tests for 
> this. Existing tests in tier1, tier2 and tier3 continue to pass after this 
> change.
> 
> 
> ---------
> - [x] I confirm that I make this contribution in accordance with the [OpenJDK 
> Interim AI Policy](https://openjdk.org/legal/ai).

This pull request has now been integrated.

Changeset: 6f7797c9
Author:    Jaikiran Pai <[email protected]>
Committer: Chen Liang <[email protected]>
URL:       
https://git.openjdk.org/valhalla/commit/6f7797c96c1c406df3403ebd7110a999cf114826
Stats:     12 lines in 1 file changed: 6 ins; 0 del; 6 mod

8386963: [lworld] Improve the exception message from Object synchronization 
methods on value objects

Reviewed-by: dholmes, alanb

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

PR: https://git.openjdk.org/valhalla/pull/2568

Reply via email to