[lworld] RFR: 8287241: Add IdentityException to report that a value object is not valid [v3]

Rémi Forax forax at openjdk.java.net
Thu Jun 9 16:01:08 UTC 2022


On Thu, 9 Jun 2022 15:00:43 GMT, Roger Riggs <rriggs at openjdk.org> wrote:

>> src/java.base/share/classes/java/lang/IdentityException.java line 69:
>> 
>>> 67:     public IdentityException(String message, Throwable cause) {
>>> 68:         super(message, cause);
>>> 69:     }
>> 
>> There is a missing variant, the one with a Throwable but no message that you use when you want to throw an IdentityException as a result of a previous exception (by example an IllegalMonitorStateException).
>
> It not clear where to draw the line on convenience methods (message can be null), but ok, added.

It's a convenient method but it's not equivalent to calling IdentityException(null, cause), Throwable(cause) is equivalent to Throwable(cause.getMessage(), cause) which is important if later a logger is configured to only log the error message.

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

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



More information about the valhalla-dev mailing list