RFR: 8279986: methods Math::asXExact for safely checked primitive casts [v2]
Joe Darcy
darcy at openjdk.java.net
Tue May 10 04:45:42 UTC 2022
On Mon, 9 May 2022 09:26:58 GMT, Raffaello Giulietti <duke at openjdk.java.net> wrote:
>> Add a family of "safe" cast methods.
>
> Raffaello Giulietti has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains four additional commits since the last revision:
>
> - 8279986: methods Math::asXExact for safely checked primitive casts
>
> Merge branch 'master' into JDK-8279986
> - 8279986: methods Math::asXExact for safely checked primitive casts
>
> Merge branch 'master' into JDK-8279986
> - 8279986: methods Math::asXExact for safely checked primitive casts
> - 8279986: methods Math::asXExact for safely checked primitive casts
src/java.base/share/classes/java/lang/Math.java line 1367:
> 1365: * Returns the value of the {@code double} argument,
> 1366: * throwing an exception if the conversion is inexact.
> 1367: * The method returns iff the argument and the result
Style suggestion: given the audience of the javadoc, rather than "iff" write out "if and only if" or other full word construct.
src/java.base/share/classes/java/lang/Math.java line 1578:
> 1576: */
> 1577: @ForceInline
> 1578: public static long toUnsignedIntExact(long value) {
Existing methods like Integer.parseUnsignedInt interpret the negative int values as positive values larger than MAX_INT. So if an int is not going to be returned here, I suggest a name like "toUnsignedIntRangeExact".
-------------
PR: https://git.openjdk.java.net/jdk/pull/8548
More information about the core-libs-dev
mailing list