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

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to