Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/java.base/share/classes/java/nio/file/FileStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import org.checkerframework.checker.interning.qual.UsesObjectEquals;
import org.checkerframework.framework.qual.AnnotatedFor;
import org.checkerframework.checker.nullness.qual.Nullable;

import java.nio.file.attribute.*;
import java.io.IOException;
Expand All @@ -46,7 +47,7 @@
* @since 1.7
*/

@AnnotatedFor({"interning"})
@AnnotatedFor({"interning", "nullness"})
public abstract @UsesObjectEquals class FileStore {

/**
Expand Down Expand Up @@ -215,7 +216,7 @@ public long getBlockSize() throws IOException {
* @return a file store attribute view of the specified type or
* {@code null} if the attribute view is not available
*/
public abstract <V extends FileStoreAttributeView> V
public abstract <V extends @Nullable FileStoreAttributeView> V
getFileStoreAttributeView(Class<V> type);

/**
Expand Down Expand Up @@ -251,5 +252,5 @@ public long getBlockSize() throws IOException {
* @throws IOException
* if an I/O error occurs
*/
public abstract Object getAttribute(String attribute) throws IOException;
public abstract @Nullable Object getAttribute(String attribute) throws IOException;
}
9 changes: 5 additions & 4 deletions src/java.base/share/classes/java/nio/file/FileSystems.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import org.checkerframework.checker.interning.qual.UsesObjectEquals;
import org.checkerframework.framework.qual.AnnotatedFor;
import org.checkerframework.checker.nullness.qual.Nullable;

import java.nio.file.spi.FileSystemProvider;
import java.net.URI;
Expand Down Expand Up @@ -89,7 +90,7 @@
* @since 1.7
*/

@AnnotatedFor({"interning"})
@AnnotatedFor({"interning", "nullness"})
public final @UsesObjectEquals class FileSystems {
private FileSystems() { }

Expand Down Expand Up @@ -331,7 +332,7 @@ public static FileSystem newFileSystem(URI uri, Map<String,?> env)
* if a security manager is installed and it denies an unspecified
* permission required by the file system provider implementation
*/
public static FileSystem newFileSystem(URI uri, Map<String,?> env, ClassLoader loader)
public static FileSystem newFileSystem(URI uri, Map<String,?> env, @Nullable ClassLoader loader)
throws IOException
{
String scheme = uri.getScheme();
Expand Down Expand Up @@ -398,7 +399,7 @@ public static FileSystem newFileSystem(URI uri, Map<String,?> env, ClassLoader l
* permission
*/
public static FileSystem newFileSystem(Path path,
ClassLoader loader)
@Nullable ClassLoader loader)
throws IOException
{
return newFileSystem(path, Map.of(), loader);
Expand Down Expand Up @@ -521,7 +522,7 @@ public static FileSystem newFileSystem(Path path) throws IOException {
* @since 13
*/
public static FileSystem newFileSystem(Path path, Map<String,?> env,
ClassLoader loader)
@Nullable ClassLoader loader)
throws IOException
{
if (path == null)
Expand Down
6 changes: 5 additions & 1 deletion src/java.base/share/classes/java/nio/file/FileVisitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
import java.nio.file.attribute.BasicFileAttributes;
import java.io.IOException;

import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.framework.qual.AnnotatedFor;

/**
* A visitor of files. An implementation of this interface is provided to the
* {@link Files#walkFileTree Files.walkFileTree} methods to visit each file in
Expand Down Expand Up @@ -95,6 +98,7 @@
* @since 1.7
*/

@AnnotatedFor({"nullness"})
public interface FileVisitor<T> {

/**
Expand Down Expand Up @@ -172,6 +176,6 @@ FileVisitResult visitFileFailed(T file, IOException exc)
* @throws IOException
* if an I/O error occurs
*/
FileVisitResult postVisitDirectory(T dir, IOException exc)
FileVisitResult postVisitDirectory(T dir, @Nullable IOException exc)
throws IOException;
}
19 changes: 10 additions & 9 deletions src/java.base/share/classes/java/nio/file/Files.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.checkerframework.dataflow.qual.SideEffectFree;
import org.checkerframework.dataflow.qual.SideEffectsOnly;
import org.checkerframework.framework.qual.AnnotatedFor;
import org.checkerframework.checker.nullness.qual.Nullable;

import java.io.BufferedReader;
import java.io.BufferedWriter;
Expand Down Expand Up @@ -103,7 +104,7 @@
* @since 1.7
*/

@AnnotatedFor({"interning", "mustcall", "signedness"})
@AnnotatedFor({"interning", "mustcall", "signedness", "nullness"})
public final @UsesObjectEquals class Files {
// buffer size used for reading and writing
private static final int BUFFER_SIZE = 8192;
Expand Down Expand Up @@ -895,8 +896,8 @@ private static void createAndCheckIsDirectory(Path dir,
*/
@ReleasesNoLocks
public static Path createTempFile(Path dir,
String prefix,
String suffix,
@Nullable String prefix,
@Nullable String suffix,
FileAttribute<?>... attrs)
throws IOException
{
Expand Down Expand Up @@ -941,8 +942,8 @@ public static Path createTempFile(Path dir,
* method is invoked to check write access to the file.
*/
@ReleasesNoLocks
public static Path createTempFile(String prefix,
String suffix,
public static Path createTempFile(@Nullable String prefix,
@Nullable String suffix,
FileAttribute<?>... attrs)
throws IOException
{
Expand Down Expand Up @@ -996,7 +997,7 @@ public static Path createTempFile(String prefix,
*/
@ReleasesNoLocks
public static Path createTempDirectory(Path dir,
String prefix,
@Nullable String prefix,
FileAttribute<?>... attrs)
throws IOException
{
Expand Down Expand Up @@ -1038,7 +1039,7 @@ public static Path createTempDirectory(Path dir,
* directory.
*/
@ReleasesNoLocks
public static Path createTempDirectory(String prefix,
public static Path createTempDirectory(@Nullable String prefix,
FileAttribute<?>... attrs)
throws IOException
{
Expand Down Expand Up @@ -1763,7 +1764,7 @@ private static List<FileTypeDetector> loadInstalledDetectors() {
* permission required by a file type detector implementation.
*/
@ReleasesNoLocks
public static String probeContentType(Path path)
public static @Nullable String probeContentType(Path path)
throws IOException
{
// try installed file type detectors
Expand Down Expand Up @@ -1822,7 +1823,7 @@ public static String probeContentType(Path path)
* the attribute view type is not available
*/
@ReleasesNoLocks
public static <V extends FileAttributeView> V getFileAttributeView(Path path,
public static <V extends @Nullable FileAttributeView> V getFileAttributeView(Path path,
Class<V> type,
LinkOption... options)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@

import java.security.BasicPermission;

import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.framework.qual.AnnotatedFor;

/**
* The {@code Permission} class for link creation operations.
*
Expand Down Expand Up @@ -66,6 +69,8 @@
* @see Files#createLink
* @see Files#createSymbolicLink
*/

@AnnotatedFor({"nullness"})
public final class LinkPermission extends BasicPermission {
@java.io.Serial
static final long serialVersionUID = -1441492453772213220L;
Expand Down Expand Up @@ -102,7 +107,7 @@ public LinkPermission(String name) {
* @throws IllegalArgumentException
* if name is empty or invalid, or actions is a non-empty string
*/
public LinkPermission(String name, String actions) {
public LinkPermission(String name, @Nullable String actions) {
super(name);
checkName(name);
if (actions != null && !actions.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
import java.util.Set;
import java.io.IOException;

import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.checker.nullness.qual.AnnotatedFor;

/**
* A {@code DirectoryStream} that defines operations on files that are located
* relative to an open directory. A {@code SecureDirectoryStream} is intended
Expand Down Expand Up @@ -56,6 +59,8 @@
* @since 1.7
*/

@AnnotatedFor({"nullness"})

public interface SecureDirectoryStream<T>
extends DirectoryStream<T>
{
Expand Down Expand Up @@ -271,7 +276,7 @@ void move(T srcpath, SecureDirectoryStream<T> targetdir, T targetpath)
* this directory stream, or {@code null} if the attribute view
* type is not available
*/
<V extends FileAttributeView> V getFileAttributeView(Class<V> type);
<V extends @Nullable FileAttributeView> V getFileAttributeView(Class<V> type);

/**
* Returns a new file attribute view to access the file attributes of a file
Expand Down Expand Up @@ -306,7 +311,7 @@ void move(T srcpath, SecureDirectoryStream<T> targetdir, T targetpath)
* type is not available
*
*/
<V extends FileAttributeView> V getFileAttributeView(T path,
<V extends @Nullable FileAttributeView> V getFileAttributeView(T path,
Class<V> type,
LinkOption... options);
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
package java.nio.file;

import org.checkerframework.checker.interning.qual.UsesObjectEquals;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.framework.qual.AnnotatedFor;

import java.nio.file.attribute.BasicFileAttributes;
Expand All @@ -43,7 +44,7 @@
* @since 1.7
*/

@AnnotatedFor({"interning"})
@AnnotatedFor({"interning", "nullness"})
public @UsesObjectEquals class SimpleFileVisitor<T> implements FileVisitor<T> {
/**
* Initializes a new instance of this class.
Expand Down Expand Up @@ -105,7 +106,7 @@ public FileVisitResult visitFileFailed(T file, IOException exc)
* of the directory to terminate prematurely.
*/
@Override
public FileVisitResult postVisitDirectory(T dir, IOException exc)
public FileVisitResult postVisitDirectory(T dir, @Nullable IOException exc)
throws IOException
{
Objects.requireNonNull(dir);
Expand Down
8 changes: 6 additions & 2 deletions src/java.base/share/classes/java/nio/file/WatchEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@

package java.nio.file;

import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.framework.qual.AnnotatedFor;

/**
* An event or a repeated event for an object that is registered with a {@link
* WatchService}.
Expand All @@ -44,15 +47,16 @@
* @since 1.7
*/

public interface WatchEvent<T> {
@AnnotatedFor({"nullness"})
public interface WatchEvent<T extends @Nullable Object> {

/**
* An event kind, for the purposes of identification.
*
* @since 1.7
* @see StandardWatchEventKinds
*/
public static interface Kind<T> {
public static interface Kind<T extends @Nullable Object> {
/**
* Returns the name of the event kind.
*
Expand Down
7 changes: 4 additions & 3 deletions src/java.base/share/classes/java/nio/file/WatchService.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

import org.checkerframework.checker.mustcall.qual.InheritableMustCall;
import org.checkerframework.framework.qual.AnnotatedFor;
import org.checkerframework.checker.nullness.qual.Nullable;

/**
* A watch service that <em>watches</em> registered objects for changes and
Expand Down Expand Up @@ -105,7 +106,7 @@
*
* @see FileSystem#newWatchService
*/
@AnnotatedFor({"mustcall"})
@AnnotatedFor({"mustcall", "nullness"})
@InheritableMustCall({})
public interface WatchService
extends Closeable
Expand Down Expand Up @@ -140,7 +141,7 @@ public interface WatchService
* @throws ClosedWatchServiceException
* if this watch service is closed
*/
WatchKey poll();
@Nullable WatchKey poll();

/**
* Retrieves and removes the next watch key, waiting if necessary up to the
Expand All @@ -160,7 +161,7 @@ public interface WatchService
* @throws InterruptedException
* if interrupted while waiting
*/
WatchKey poll(long timeout, TimeUnit unit)
@Nullable WatchKey poll(long timeout, TimeUnit unit)
throws InterruptedException;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@

import java.io.IOException;

import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.framework.qual.AnnotatedFor;

/**
* A file attribute view that provides a view of a <em>basic set</em> of file
* attributes common to many file systems. The basic set of file attributes
Expand Down Expand Up @@ -101,6 +104,7 @@
* @since 1.7
*/

@AnnotatedFor({"nullness"})
public interface BasicFileAttributeView
extends FileAttributeView
{
Expand Down Expand Up @@ -176,7 +180,7 @@ public interface BasicFileAttributeView
*
* @see java.nio.file.Files#setLastModifiedTime
*/
void setTimes(FileTime lastModifiedTime,
FileTime lastAccessTime,
FileTime createTime) throws IOException;
void setTimes(@Nullable FileTime lastModifiedTime,
@Nullable FileTime lastAccessTime,
@Nullable FileTime createTime) throws IOException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import org.checkerframework.checker.index.qual.NonNegative;
import org.checkerframework.framework.qual.AnnotatedFor;
import org.checkerframework.checker.nullness.qual.Nullable;

/**
* Basic attributes associated with a file in a file system.
Expand All @@ -46,7 +47,7 @@
* @see BasicFileAttributeView
*/

@AnnotatedFor({"index"})
@AnnotatedFor({"index", "nullness"})
public interface BasicFileAttributes {

/**
Expand Down Expand Up @@ -155,5 +156,5 @@ public interface BasicFileAttributes {
*
* @see java.nio.file.Files#walkFileTree
*/
Object fileKey();
@Nullable Object fileKey();
}
Loading
Loading