RFR: 8357913: Add `@Stable` to BigInteger and BigDecimal [v2]

Raffaello Giulietti rgiulietti at openjdk.org
Wed Jun 4 13:55:53 UTC 2025


On Fri, 30 May 2025 22:21:34 GMT, Shaojin Wen <swen at openjdk.org> wrote:

>> src/java.base/share/classes/java/math/BigInteger.java line 192:
>> 
>>> 190:      * zero-length mag array.
>>> 191:      */
>>> 192:     @Stable
>> 
>> `BigInteger.mag` gets written to a few times during computation in `BigInteger​.largePrime(…)`: <https://github.com/openjdk/jdk/blob/db340e54f83cf7bf72abb94c9cf9cdac007ed38a/src/java.base/share/classes/java/math/BigInteger.java#L886-L887><https://github.com/openjdk/jdk/blob/db340e54f83cf7bf72abb94c9cf9cdac007ed38a/src/java.base/share/classes/java/math/BigInteger.java#L895-L898>
>
> BigInteger is an object that is considered immutable, but its field mag is actually changed. This is incredible and should be fixed here. It is easy to make mistakes.

Please do _not_ fix the `mag` issue in this PR.
I'll take care of it in a future PR.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25437#discussion_r2126665207


More information about the core-libs-dev mailing list