Skip to content

Commit 1973fa0

Browse files
authored
Receiver of orElseThrow(Supplier) is @MaybePresent
1 parent 2e95e32 commit 1973fa0

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/java.base/share/classes/java/util/Optional.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,8 +434,10 @@ public T orElseThrow(@Present Optional<T> this) {
434434
* @throws NullPointerException if no value is present and the exception
435435
* supplying function is {@code null}
436436
*/
437+
@CFComment({"optional: orElseThrow(Supplier) does not throw NoSuchElementException, so its receiver is @MaybePresent.",
438+
"Contrast with orElseThrow(), defined just above, whose receiver is @Present."})
437439
@EnsuresQualifier(expression = "this", qualifier = Present.class)
438-
public <X extends Throwable> T orElseThrow(@Present Optional<T> this, Supplier<? extends X> exceptionSupplier) throws X {
440+
public <X extends Throwable> T orElseThrow(Supplier<? extends X> exceptionSupplier) throws X {
439441
if (value != null) {
440442
return value;
441443
} else {

0 commit comments

Comments
 (0)