RFR: 8170389: java.text.DigitList.getDouble() : Controversy between javadoc and code

Naoto Sato naoto at openjdk.org
Wed Oct 5 18:35:25 UTC 2022


On Tue, 4 Oct 2022 23:11:57 GMT, Justin Lu <duke at openjdk.org> wrote:

> Problem: Outdated doc does not match code. Claimed to throw exception and compared to Long method.
> Fix: Update doc to match code, compared to Double.parseDouble() accordingly.

Turned out that the comment was not aligning with the behavior of `Double.parseDouble("")`, as it throws `NumberFormatException` (Thanks to @LanceAndersen who let me know). So how about changing it to:

If (count == 0) this returns 0.0, unlike Double.parseDouble("") which throws NumberFormatException

It also applies to `getLong()`, and you may want to add comments `getBigDecimal()` for consistency with other `getXXX()` methods (without "unlike ..." part though).

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

PR: https://git.openjdk.org/jdk/pull/10567


More information about the core-libs-dev mailing list