Skip to content

Commit

Permalink
Add @NonNull annotations to @NullUnmarked APIs. (#110)
Browse files Browse the repository at this point in the history
While [we're not sure about the attribute
values](#10 (review)),
we believe that everything else is non-null.

I hadn't thought of using `@NonNull` back then, but it occurred to me
after I put together #109.

Co-authored-by: Werner Dietl <[email protected]>
  • Loading branch information
cpovirk and wmdietl authored Dec 18, 2024
1 parent e717491 commit 7cc2fbd
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/java.base/share/classes/java/nio/file/Files.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
import java.util.stream.Stream;
import java.util.stream.StreamSupport;

import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.NullUnmarked;
import org.jspecify.annotations.Nullable;
Expand Down Expand Up @@ -1814,9 +1815,9 @@ public static Path setAttribute(Path path, String attribute, Object value,
* @throws IOException
* if an I/O error occurs
*/
@NullUnmarked
public static Object getAttribute(Path path, String attribute,
LinkOption... options)
@NullUnmarked // https://github.com/jspecify/jdk/pull/10#pullrequestreview-1404320091
public static /*@NullUnmarked*/ Object getAttribute(@NonNull Path path, @NonNull String attribute,
@NonNull LinkOption @NonNull ... options)
throws IOException
{
// only one attribute should be read
Expand Down Expand Up @@ -1913,9 +1914,9 @@ public static Object getAttribute(Path path, String attribute,
* @throws IOException
* if an I/O error occurs
*/
@NullUnmarked
public static Map<String,Object> readAttributes(Path path, String attributes,
LinkOption... options)
@NullUnmarked // https://github.com/jspecify/jdk/pull/10#pullrequestreview-1404320091
public static @NonNull Map<@NonNull String, /*@NullUnmarked*/ Object> readAttributes(@NonNull Path path, @NonNull String attributes,
@NonNull LinkOption @NonNull ... options)
throws IOException
{
return provider(path).readAttributes(path, attributes, options);
Expand Down

0 comments on commit 7cc2fbd

Please sign in to comment.