RFR: 8077587: BigInteger Roots [v45]

Raffaello Giulietti rgiulietti at openjdk.org
Fri Jul 25 15:42:58 UTC 2025


On Fri, 25 Jul 2025 15:18:00 GMT, fabioromano1 <duke at openjdk.org> wrote:

>> src/java.base/share/classes/java/math/MutableBigInteger.java line 1934:
>> 
>>> 1932:             return new MutableBigInteger[] { this, new MutableBigInteger() };
>>> 1933: 
>>> 1934:         final int bitLength = (int) this.bitLength();
>> 
>> The method does not state that it is assuming that `bitLength()` fits in an `int`.
>
> Indeed, I did not stated it because I was not sure if it were better to assume that `bitLength()` fits in an `int`, or to throw an `ArithmeticException` instead if it doesn't...

Not sure.
The method makes other assumptions that are not checked. Since the class is not public, that might be OK if the assumptions are all stated correctly.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/24898#discussion_r2231455849


More information about the core-libs-dev mailing list