High cost of failed Math.*Exact calls

Charles Oliver Nutter headius at headius.com
Fri Dec 13 01:00:14 UTC 2024


On Thu, Dec 12, 2024 at 6:22 PM Ethan McCue <ethan at mccue.dev> wrote:

> Placement in the standard library aside, I think Java needs value types
> and patterns before a non-throwing version of Math.multiplyExact can be
> made that achieves the same semantic goals.
>
> switch (Maths.multiplyExact(a, b)) {
>     case Product.of(long result) -> {}
>     case Product.overflow() -> {}
> }
>

Well, for that matter, if methods that receive lambdas could inline along
with the lambda, the error path could just be a passed in lambda. But since
we're not there yet I'm looking for short-term options to use the *Exact
functions without causing massive overhead when they overflow.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/core-libs-dev/attachments/20241212/a624ed41/attachment.htm>


More information about the core-libs-dev mailing list