Skip to content

Commit

Permalink
Annotate ScopedValue.orElse. (#93)
Browse files Browse the repository at this point in the history
I'm doing this entirely in response to an observation that this is a new
API that would benefit from `@PolyNull`:

eclipse-jdt/eclipse.jdt.core#2147 (comment)

I haven't tried to annotate the rest of the class.
  • Loading branch information
cpovirk authored Oct 7, 2024
1 parent 783f02c commit 3e9473d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/java.base/share/classes/java/lang/ScopedValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

package java.lang;

import org.jspecify.annotations.Nullable;

import java.util.NoSuchElementException;
import java.util.Objects;
import java.lang.ref.Reference;
Expand Down Expand Up @@ -684,7 +686,7 @@ private Object findBinding() {
* @param other the value to return if not bound, can be {@code null}
* @return the value of the scoped value if bound, otherwise {@code other}
*/
public T orElse(T other) {
public @Nullable T orElse(@Nullable T other) {
Object obj = findBinding();
if (obj != Snapshot.NIL) {
@SuppressWarnings("unchecked")
Expand Down

0 comments on commit 3e9473d

Please sign in to comment.