On Mon, 30 Mar 2026 20:44:32 GMT, Serguei Spitsyn <[email protected]> wrote:

>> Alan Bateman has updated the pull request incrementally with one additional 
>> commit since the last revision:
>> 
>>   Fix indent
>
> test/lib/jdk/test/lib/json/JSONValue.java line 669:
> 
>> 667: 
>> 668:     default double asDouble() {
>> 669:         throw new UnsupportedOperationException("Unsupported conversion 
>> to number");
> 
> Nit: Messages at lines 661, 665 and 669 could be more specific, e.g. saying:
>   "Unsupported conversion to double".
> But maybe current messages are intentional?

The exception is when the value isn't a JSONNumber. If the conversion to double 
fails then NumberFormatException is thrown.

There is a [draft JEP](https://openjdk.org/jeps/8344154) proposing an 
API/methods to read json so eventually we should be able to remove this test 
class. The equivalent method in that API is toDouble (but might be renamed) 
would throw "JsonAssertionException: JsonString is not a JsonNumber", following 
by the path to the member, its line number, and position. The test class could 
be improved but I'm assuming it will be deleted so didn't spent a lot of time 
improving the diagnostics.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/30467#discussion_r3013774421

Reply via email to