Skip to content

Commit

Permalink
Add @NonNull annotations to @NullUnmarked APIs.
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.
  • Loading branch information
cpovirk committed Nov 22, 2024
1 parent 457b292 commit de250bc
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 @@ -81,6 +81,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 @@ -1996,9 +1997,9 @@ public static Path setAttribute(Path path, String attribute, Object value,
* to read security sensitive attributes then the security manager
* may be invoked to check for additional permissions.
*/
@NullUnmarked
public static Object getAttribute(Path path, String attribute,
LinkOption... options)
@NullUnmarked // https://github.com/jspecify/jdk/pull/10#pullrequestreview-1404320091
public static Object getAttribute(@NonNull Path path, @NonNull String attribute,
@NonNull LinkOption @NonNull ... options)
throws IOException
{
// only one attribute should be read
Expand Down Expand Up @@ -2101,9 +2102,9 @@ public static Object getAttribute(Path path, String attribute,
* to read security sensitive attributes then the security manager
* may be invoked to check for additional permissions.
*/
@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,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 de250bc

Please sign in to comment.