Wrong exception in ComputedConstant#orElse Javadoc
Daniel Schmid
daniel at wwwmaster.at
Wed Aug 9 10:58:06 UTC 2023
I created a PR for that to the branch in the leyden repository:
https://github.com/openjdk/leyden/pull/1
Am 04.08.2023 um 18:55 schrieb Daniel Schmid:
> When viewing the propsed Javadoc of ComputedConstant#orElse
> (https://cr.openjdk.org/~pminborg/computed-constant/api/java.base/java/lang/ComputedConstant.html#orElse(V)),it
> mentions throwing an NoSuchElementException in case the element cannot
> be bound.
> However, the Javadoc also mentions returning the passed value in that
> case.
>
> If we take a look at the code for that in the Leyden repository
> (https://github.com/openjdk/leyden/blob/b9219784cc277417dc112a7fbf652bdc021cf806/src/java.base/share/classes/jdk/internal/constant/AbstractComputedConstant.java#L127
> and
> https://github.com/openjdk/leyden/blob/b9219784cc277417dc112a7fbf652bdc021cf806/src/java.base/share/classes/jdk/internal/constant/AbstractComputedConstant.java#L161C27-L161C27),
> we can see that "rethrow" is false and no NoSuchElementException is
> thrown
> (https://github.com/openjdk/leyden/blob/b9219784cc277417dc112a7fbf652bdc021cf806/src/java.base/share/classes/jdk/internal/constant/AbstractComputedConstant.java#L183-L186).
>
> I think the "@throws NoSuchElementException" should be removed from
> ComputedConstant#orElse
> (https://github.com/openjdk/leyden/blob/b9219784cc277417dc112a7fbf652bdc021cf806/src/java.base/share/classes/java/lang/ComputedConstant.java#L294C19-L294C19)
>
> Yours,
> Daniel
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4490 bytes
Desc: S/MIME Cryptographic Signature
URL: <https://mail.openjdk.org/pipermail/leyden-dev/attachments/20230809/d600fc7f/smime.p7s>
More information about the leyden-dev
mailing list