From dad7446acae6019fcfb2e997205935b2ee8e4aad Mon Sep 17 00:00:00 2001 From: Davy Landman Date: Thu, 9 Oct 2025 12:30:54 +0200 Subject: [PATCH] Annotated io/nio/concurrent exceptions --- src/java.base/share/classes/java/io/EOFException.java | 6 +++++- .../share/classes/java/io/FileNotFoundException.java | 7 +++++-- src/java.base/share/classes/java/io/IOError.java | 5 ++++- .../share/classes/java/io/NotActiveException.java | 6 +++++- .../classes/java/io/NotSerializableException.java | 6 +++++- .../share/classes/java/io/OptionalDataException.java | 3 +++ .../classes/java/io/StreamCorruptedException.java | 5 ++++- .../share/classes/java/io/SyncFailedException.java | 6 +++++- .../share/classes/java/io/UTFDataFormatException.java | 6 +++++- .../classes/java/io/UnsupportedEncodingException.java | 6 +++++- .../share/classes/java/io/WriteAbortedException.java | 6 ++++-- .../classes/java/nio/file/AccessDeniedException.java | 9 ++++++--- .../java/nio/file/AtomicMoveNotSupportedException.java | 10 +++++++--- .../java/nio/file/DirectoryIteratorException.java | 4 ++++ .../java/nio/file/DirectoryNotEmptyException.java | 5 ++++- .../java/nio/file/FileAlreadyExistsException.java | 8 ++++++-- .../nio/file/FileSystemAlreadyExistsException.java | 6 +++++- .../classes/java/nio/file/FileSystemLoopException.java | 6 +++++- .../java/nio/file/FileSystemNotFoundException.java | 6 +++++- .../classes/java/nio/file/InvalidPathException.java | 3 +++ .../classes/java/nio/file/NoSuchFileException.java | 8 ++++++-- .../classes/java/nio/file/NotDirectoryException.java | 6 +++++- .../share/classes/java/nio/file/NotLinkException.java | 8 ++++++-- .../java/nio/file/ProviderMismatchException.java | 6 +++++- .../java/nio/file/ProviderNotFoundException.java | 6 +++++- .../java/nio/file/ReadOnlyFileSystemException.java | 3 +++ .../java/util/concurrent/BrokenBarrierException.java | 6 +++++- .../java/util/concurrent/CompletionException.java | 10 +++++++--- .../util/concurrent/RejectedExecutionException.java | 10 +++++++--- 29 files changed, 144 insertions(+), 38 deletions(-) diff --git a/src/java.base/share/classes/java/io/EOFException.java b/src/java.base/share/classes/java/io/EOFException.java index dcc1315e76235..ab2b9a86ba14e 100644 --- a/src/java.base/share/classes/java/io/EOFException.java +++ b/src/java.base/share/classes/java/io/EOFException.java @@ -25,6 +25,9 @@ package java.io; +import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.framework.qual.AnnotatedFor; + /** * Signals that an end of file or end of stream has been reached * unexpectedly during input. @@ -38,6 +41,7 @@ * @see java.io.IOException * @since 1.0 */ +@AnnotatedFor({"nullness"}) public class EOFException extends IOException { @java.io.Serial private static final long serialVersionUID = 6433858223774886977L; @@ -58,7 +62,7 @@ public EOFException() { * * @param s the detail message. */ - public EOFException(String s) { + public EOFException(@Nullable String s) { super(s); } } diff --git a/src/java.base/share/classes/java/io/FileNotFoundException.java b/src/java.base/share/classes/java/io/FileNotFoundException.java index 8d13aa3fdb93c..331447c4d7b4c 100644 --- a/src/java.base/share/classes/java/io/FileNotFoundException.java +++ b/src/java.base/share/classes/java/io/FileNotFoundException.java @@ -25,6 +25,8 @@ package java.io; +import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.framework.qual.AnnotatedFor; /** * Signals that an attempt to open the file denoted by a specified pathname @@ -39,6 +41,7 @@ * @since 1.0 */ +@AnnotatedFor({"nullness"}) public class FileNotFoundException extends IOException { @java.io.Serial private static final long serialVersionUID = -897856973823710492L; @@ -60,7 +63,7 @@ public FileNotFoundException() { * * @param s the detail message. */ - public FileNotFoundException(String s) { + public FileNotFoundException(@Nullable String s) { super(s); } @@ -73,7 +76,7 @@ public FileNotFoundException(String s) { * * @since 1.2 */ - private FileNotFoundException(String path, String reason) { + private FileNotFoundException(String path, @Nullable String reason) { super(path + ((reason == null) ? "" : " (" + reason + ")")); diff --git a/src/java.base/share/classes/java/io/IOError.java b/src/java.base/share/classes/java/io/IOError.java index 622143db9a892..1d6e6fbe2ab33 100644 --- a/src/java.base/share/classes/java/io/IOError.java +++ b/src/java.base/share/classes/java/io/IOError.java @@ -25,12 +25,15 @@ package java.io; +import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.framework.qual.AnnotatedFor; /** * Thrown when a serious I/O error has occurred. * * @author Xueming Shen * @since 1.6 */ +@AnnotatedFor({"nullness"}) public class IOError extends Error { /** * Constructs a new instance of IOError with the specified cause. The @@ -42,7 +45,7 @@ public class IOError extends Error { * The cause of this error, or {@code null} if the cause * is not known */ - public IOError(Throwable cause) { + public IOError(@Nullable Throwable cause) { super(cause); } diff --git a/src/java.base/share/classes/java/io/NotActiveException.java b/src/java.base/share/classes/java/io/NotActiveException.java index 3b8b281cbf4ea..7835518fdd0c4 100644 --- a/src/java.base/share/classes/java/io/NotActiveException.java +++ b/src/java.base/share/classes/java/io/NotActiveException.java @@ -25,11 +25,15 @@ package java.io; +import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.framework.qual.AnnotatedFor; + /** * Thrown when serialization or deserialization is not active. * * @since 1.1 */ +@AnnotatedFor({"nullness"}) public class NotActiveException extends ObjectStreamException { @java.io.Serial @@ -40,7 +44,7 @@ public class NotActiveException extends ObjectStreamException { * * @param reason a String describing the reason for the exception. */ - public NotActiveException(String reason) { + public NotActiveException(@Nullable String reason) { super(reason); } diff --git a/src/java.base/share/classes/java/io/NotSerializableException.java b/src/java.base/share/classes/java/io/NotSerializableException.java index d1010188272f4..a660b09e233b8 100644 --- a/src/java.base/share/classes/java/io/NotSerializableException.java +++ b/src/java.base/share/classes/java/io/NotSerializableException.java @@ -25,6 +25,9 @@ package java.io; +import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.framework.qual.AnnotatedFor; + /** * Thrown when an instance is required to have a Serializable interface. * The serialization runtime or the class of the instance can throw @@ -32,6 +35,7 @@ * * @since 1.1 */ +@AnnotatedFor({"nullness"}) public class NotSerializableException extends ObjectStreamException { @java.io.Serial @@ -42,7 +46,7 @@ public class NotSerializableException extends ObjectStreamException { * * @param classname Class of the instance being serialized/deserialized. */ - public NotSerializableException(String classname) { + public NotSerializableException(@Nullable String classname) { super(classname); } diff --git a/src/java.base/share/classes/java/io/OptionalDataException.java b/src/java.base/share/classes/java/io/OptionalDataException.java index f98bf079e8e86..e62169b36fd99 100644 --- a/src/java.base/share/classes/java/io/OptionalDataException.java +++ b/src/java.base/share/classes/java/io/OptionalDataException.java @@ -24,6 +24,8 @@ */ package java.io; +import org.checkerframework.framework.qual.AnnotatedFor; + /** * Exception indicating the failure of an object read operation due to * unread primitive data, or the end of data belonging to a serialized @@ -44,6 +46,7 @@ * * @since 1.1 */ +@AnnotatedFor({"nullness"}) public class OptionalDataException extends ObjectStreamException { @java.io.Serial diff --git a/src/java.base/share/classes/java/io/StreamCorruptedException.java b/src/java.base/share/classes/java/io/StreamCorruptedException.java index 5124c5ce65700..408443f8a5b39 100644 --- a/src/java.base/share/classes/java/io/StreamCorruptedException.java +++ b/src/java.base/share/classes/java/io/StreamCorruptedException.java @@ -25,12 +25,15 @@ package java.io; +import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.framework.qual.AnnotatedFor; /** * Thrown when control information that was read from an object stream * violates internal consistency checks. * * @since 1.1 */ +@AnnotatedFor({"nullness"}) public class StreamCorruptedException extends ObjectStreamException { @java.io.Serial @@ -41,7 +44,7 @@ public class StreamCorruptedException extends ObjectStreamException { * * @param reason String describing the reason for the exception. */ - public StreamCorruptedException(String reason) { + public StreamCorruptedException(@Nullable String reason) { super(reason); } diff --git a/src/java.base/share/classes/java/io/SyncFailedException.java b/src/java.base/share/classes/java/io/SyncFailedException.java index e940b5a7e562d..aedabf3add3cd 100644 --- a/src/java.base/share/classes/java/io/SyncFailedException.java +++ b/src/java.base/share/classes/java/io/SyncFailedException.java @@ -25,6 +25,9 @@ package java.io; +import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.framework.qual.AnnotatedFor; + /** * Signals that a sync operation has failed. * @@ -33,6 +36,7 @@ * @see java.io.IOException * @since 1.1 */ +@AnnotatedFor({"nullness"}) public class SyncFailedException extends IOException { @java.io.Serial private static final long serialVersionUID = -2353342684412443330L; @@ -43,7 +47,7 @@ public class SyncFailedException extends IOException { * * @param desc a String describing the exception. */ - public SyncFailedException(String desc) { + public SyncFailedException(@Nullable String desc) { super(desc); } } diff --git a/src/java.base/share/classes/java/io/UTFDataFormatException.java b/src/java.base/share/classes/java/io/UTFDataFormatException.java index bb8eb3b7d81b6..cc45ea2d3d37d 100644 --- a/src/java.base/share/classes/java/io/UTFDataFormatException.java +++ b/src/java.base/share/classes/java/io/UTFDataFormatException.java @@ -25,6 +25,9 @@ package java.io; +import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.framework.qual.AnnotatedFor; + /** * Signals that a malformed string in * modified UTF-8 @@ -42,6 +45,7 @@ * @see java.io.IOException * @since 1.0 */ +@AnnotatedFor({"nullness"}) public class UTFDataFormatException extends IOException { @java.io.Serial private static final long serialVersionUID = 420743449228280612L; @@ -63,7 +67,7 @@ public UTFDataFormatException() { * * @param s the detail message. */ - public UTFDataFormatException(String s) { + public UTFDataFormatException(@Nullable String s) { super(s); } } diff --git a/src/java.base/share/classes/java/io/UnsupportedEncodingException.java b/src/java.base/share/classes/java/io/UnsupportedEncodingException.java index b80f453f5c60f..48440f8ae19c6 100644 --- a/src/java.base/share/classes/java/io/UnsupportedEncodingException.java +++ b/src/java.base/share/classes/java/io/UnsupportedEncodingException.java @@ -24,12 +24,16 @@ */ package java.io; +import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.framework.qual.AnnotatedFor; + /** * The Character Encoding is not supported. * * @author Asmus Freytag * @since 1.1 */ +@AnnotatedFor({"nullness"}) public class UnsupportedEncodingException extends IOException { @@ -47,7 +51,7 @@ public UnsupportedEncodingException() { * Constructs an UnsupportedEncodingException with a detail message. * @param s Describes the reason for the exception. */ - public UnsupportedEncodingException(String s) { + public UnsupportedEncodingException(@Nullable String s) { super(s); } } diff --git a/src/java.base/share/classes/java/io/WriteAbortedException.java b/src/java.base/share/classes/java/io/WriteAbortedException.java index a179d2d669c38..c4f3ed55d31d5 100644 --- a/src/java.base/share/classes/java/io/WriteAbortedException.java +++ b/src/java.base/share/classes/java/io/WriteAbortedException.java @@ -26,6 +26,7 @@ package java.io; import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.framework.qual.AnnotatedFor; /** * Signals that one of the ObjectStreamExceptions was thrown during a @@ -37,6 +38,7 @@ * * @since 1.1 */ +@AnnotatedFor({"nullness"}) public class WriteAbortedException extends ObjectStreamException { @java.io.Serial private static final long serialVersionUID = -3326426625597282442L; @@ -51,7 +53,7 @@ public class WriteAbortedException extends ObjectStreamException { * @serial */ @Deprecated(since="17") - public Exception detail; + public @Nullable Exception detail; /** * Constructs a WriteAbortedException with a string describing @@ -59,7 +61,7 @@ public class WriteAbortedException extends ObjectStreamException { * @param s String describing the exception. * @param ex Exception causing the abort. */ - public WriteAbortedException(String s, Exception ex) { + public WriteAbortedException(@Nullable String s, @Nullable Exception ex) { super(s); initCause(null); // Disallow subsequent initCause detail = ex; diff --git a/src/java.base/share/classes/java/nio/file/AccessDeniedException.java b/src/java.base/share/classes/java/nio/file/AccessDeniedException.java index 10f0fda39559f..d45fca83c0b75 100644 --- a/src/java.base/share/classes/java/nio/file/AccessDeniedException.java +++ b/src/java.base/share/classes/java/nio/file/AccessDeniedException.java @@ -25,6 +25,9 @@ package java.nio.file; +import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.framework.qual.AnnotatedFor; + /** * Checked exception thrown when a file system operation is denied, typically * due to a file permission or other access check. @@ -36,7 +39,7 @@ * * @since 1.7 */ - +@AnnotatedFor({"nullness"}) public class AccessDeniedException extends FileSystemException { @@ -49,7 +52,7 @@ public class AccessDeniedException * @param file * a string identifying the file or {@code null} if not known */ - public AccessDeniedException(String file) { + public AccessDeniedException(@Nullable String file) { super(file); } @@ -63,7 +66,7 @@ public AccessDeniedException(String file) { * @param reason * a reason message with additional information or {@code null} */ - public AccessDeniedException(String file, String other, String reason) { + public AccessDeniedException(@Nullable String file, @Nullable String other, @Nullable String reason) { super(file, other, reason); } } diff --git a/src/java.base/share/classes/java/nio/file/AtomicMoveNotSupportedException.java b/src/java.base/share/classes/java/nio/file/AtomicMoveNotSupportedException.java index e08ba0a343cb0..59a6035048556 100644 --- a/src/java.base/share/classes/java/nio/file/AtomicMoveNotSupportedException.java +++ b/src/java.base/share/classes/java/nio/file/AtomicMoveNotSupportedException.java @@ -25,6 +25,9 @@ package java.nio.file; +import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.framework.qual.AnnotatedFor; + /** * Checked exception thrown when a file cannot be moved as an atomic file system * operation. @@ -32,6 +35,7 @@ * @since 1.7 */ +@AnnotatedFor({"nullness"}) public class AtomicMoveNotSupportedException extends FileSystemException { @@ -48,9 +52,9 @@ public class AtomicMoveNotSupportedException * @param reason * a reason message with additional information or {@code null} */ - public AtomicMoveNotSupportedException(String source, - String target, - String reason) + public AtomicMoveNotSupportedException(@Nullable String source, + @Nullable String target, + @Nullable String reason) { super(source, target, reason); } diff --git a/src/java.base/share/classes/java/nio/file/DirectoryIteratorException.java b/src/java.base/share/classes/java/nio/file/DirectoryIteratorException.java index 51fb08759e027..5944e3d4a4a07 100644 --- a/src/java.base/share/classes/java/nio/file/DirectoryIteratorException.java +++ b/src/java.base/share/classes/java/nio/file/DirectoryIteratorException.java @@ -31,6 +31,9 @@ import java.io.ObjectInputStream; import java.io.InvalidObjectException; +import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.framework.qual.AnnotatedFor; + /** * Runtime exception thrown if an I/O error is encountered when iterating over * the entries in a directory. The I/O error is retrieved as an {@link @@ -40,6 +43,7 @@ * @see DirectoryStream */ +@AnnotatedFor({"nullness"}) public final class DirectoryIteratorException extends ConcurrentModificationException { diff --git a/src/java.base/share/classes/java/nio/file/DirectoryNotEmptyException.java b/src/java.base/share/classes/java/nio/file/DirectoryNotEmptyException.java index 563e0830f0657..1dc2c7543ba2c 100644 --- a/src/java.base/share/classes/java/nio/file/DirectoryNotEmptyException.java +++ b/src/java.base/share/classes/java/nio/file/DirectoryNotEmptyException.java @@ -25,6 +25,8 @@ package java.nio.file; +import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.framework.qual.AnnotatedFor; /** * Checked exception thrown when a file system operation fails because a * directory is not empty. @@ -32,6 +34,7 @@ * @since 1.7 */ +@AnnotatedFor({"nullness"}) public class DirectoryNotEmptyException extends FileSystemException { @@ -44,7 +47,7 @@ public class DirectoryNotEmptyException * @param dir * a string identifying the directory or {@code null} if not known */ - public DirectoryNotEmptyException(String dir) { + public DirectoryNotEmptyException(@Nullable String dir) { super(dir); } } diff --git a/src/java.base/share/classes/java/nio/file/FileAlreadyExistsException.java b/src/java.base/share/classes/java/nio/file/FileAlreadyExistsException.java index 90fcbba25be01..0586d5e28f4e7 100644 --- a/src/java.base/share/classes/java/nio/file/FileAlreadyExistsException.java +++ b/src/java.base/share/classes/java/nio/file/FileAlreadyExistsException.java @@ -25,6 +25,9 @@ package java.nio.file; +import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.framework.qual.AnnotatedFor; + /** * Checked exception thrown when an attempt is made to create a file or * directory and a file of that name already exists. @@ -32,6 +35,7 @@ * @since 1.7 */ +@AnnotatedFor({"nullness"}) public class FileAlreadyExistsException extends FileSystemException { @@ -44,7 +48,7 @@ public class FileAlreadyExistsException * @param file * a string identifying the file or {@code null} if not known */ - public FileAlreadyExistsException(String file) { + public FileAlreadyExistsException(@Nullable String file) { super(file); } @@ -58,7 +62,7 @@ public FileAlreadyExistsException(String file) { * @param reason * a reason message with additional information or {@code null} */ - public FileAlreadyExistsException(String file, String other, String reason) { + public FileAlreadyExistsException(@Nullable String file, @Nullable String other, @Nullable String reason) { super(file, other, reason); } } diff --git a/src/java.base/share/classes/java/nio/file/FileSystemAlreadyExistsException.java b/src/java.base/share/classes/java/nio/file/FileSystemAlreadyExistsException.java index 0f4be9f393a6f..afa5750db970f 100644 --- a/src/java.base/share/classes/java/nio/file/FileSystemAlreadyExistsException.java +++ b/src/java.base/share/classes/java/nio/file/FileSystemAlreadyExistsException.java @@ -25,6 +25,9 @@ package java.nio.file; +import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.framework.qual.AnnotatedFor; + /** * Runtime exception thrown when an attempt is made to create a file system that * already exists. @@ -32,6 +35,7 @@ * @since 1.7 */ +@AnnotatedFor({"nullness"}) public class FileSystemAlreadyExistsException extends RuntimeException { @@ -50,7 +54,7 @@ public FileSystemAlreadyExistsException() { * @param msg * the detail message */ - public FileSystemAlreadyExistsException(String msg) { + public FileSystemAlreadyExistsException(@Nullable String msg) { super(msg); } } diff --git a/src/java.base/share/classes/java/nio/file/FileSystemLoopException.java b/src/java.base/share/classes/java/nio/file/FileSystemLoopException.java index 0cea2e94abfae..b0e0df2dd362d 100644 --- a/src/java.base/share/classes/java/nio/file/FileSystemLoopException.java +++ b/src/java.base/share/classes/java/nio/file/FileSystemLoopException.java @@ -25,6 +25,9 @@ package java.nio.file; +import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.framework.qual.AnnotatedFor; + /** * Checked exception thrown when a file system loop, or cycle, is encountered. * @@ -32,6 +35,7 @@ * @see Files#walkFileTree */ +@AnnotatedFor({"nullness"}) public class FileSystemLoopException extends FileSystemException { @@ -45,7 +49,7 @@ public class FileSystemLoopException * a string identifying the file causing the cycle or {@code null} if * not known */ - public FileSystemLoopException(String file) { + public FileSystemLoopException(@Nullable String file) { super(file); } } diff --git a/src/java.base/share/classes/java/nio/file/FileSystemNotFoundException.java b/src/java.base/share/classes/java/nio/file/FileSystemNotFoundException.java index 0b170fba9a7b3..c26f478007ec5 100644 --- a/src/java.base/share/classes/java/nio/file/FileSystemNotFoundException.java +++ b/src/java.base/share/classes/java/nio/file/FileSystemNotFoundException.java @@ -25,12 +25,16 @@ package java.nio.file; + +import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.framework.qual.AnnotatedFor; /** * Runtime exception thrown when a file system cannot be found. * * @since 1.7 */ +@AnnotatedFor({"nullness"}) public class FileSystemNotFoundException extends RuntimeException { @@ -49,7 +53,7 @@ public FileSystemNotFoundException() { * @param msg * the detail message */ - public FileSystemNotFoundException(String msg) { + public FileSystemNotFoundException(@Nullable String msg) { super(msg); } } diff --git a/src/java.base/share/classes/java/nio/file/InvalidPathException.java b/src/java.base/share/classes/java/nio/file/InvalidPathException.java index bb28b61b83b9a..83f77419327f5 100644 --- a/src/java.base/share/classes/java/nio/file/InvalidPathException.java +++ b/src/java.base/share/classes/java/nio/file/InvalidPathException.java @@ -25,6 +25,8 @@ package java.nio.file; +import org.checkerframework.framework.qual.AnnotatedFor; + /** * Unchecked exception thrown when path string cannot be converted into a * {@link Path} because the path string contains invalid characters, or @@ -33,6 +35,7 @@ * @since 1.7 */ +@AnnotatedFor({"nullness"}) public class InvalidPathException extends IllegalArgumentException { diff --git a/src/java.base/share/classes/java/nio/file/NoSuchFileException.java b/src/java.base/share/classes/java/nio/file/NoSuchFileException.java index 73c37e60d573d..56858158e39c1 100644 --- a/src/java.base/share/classes/java/nio/file/NoSuchFileException.java +++ b/src/java.base/share/classes/java/nio/file/NoSuchFileException.java @@ -25,6 +25,9 @@ package java.nio.file; +import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.framework.qual.AnnotatedFor; + /** * Checked exception thrown when an attempt is made to access a file that does * not exist. @@ -32,6 +35,7 @@ * @since 1.7 */ +@AnnotatedFor({"nullness"}) public class NoSuchFileException extends FileSystemException { @@ -44,7 +48,7 @@ public class NoSuchFileException * @param file * a string identifying the file or {@code null} if not known. */ - public NoSuchFileException(String file) { + public NoSuchFileException(@Nullable String file) { super(file); } @@ -58,7 +62,7 @@ public NoSuchFileException(String file) { * @param reason * a reason message with additional information or {@code null} */ - public NoSuchFileException(String file, String other, String reason) { + public NoSuchFileException(@Nullable String file, @Nullable String other, @Nullable String reason) { super(file, other, reason); } } diff --git a/src/java.base/share/classes/java/nio/file/NotDirectoryException.java b/src/java.base/share/classes/java/nio/file/NotDirectoryException.java index 225bd2494ff5a..bad62317c7715 100644 --- a/src/java.base/share/classes/java/nio/file/NotDirectoryException.java +++ b/src/java.base/share/classes/java/nio/file/NotDirectoryException.java @@ -25,6 +25,9 @@ package java.nio.file; +import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.framework.qual.AnnotatedFor; + /** * Checked exception thrown when a file system operation, intended for a * directory, fails because the file is not a directory. @@ -32,6 +35,7 @@ * @since 1.7 */ +@AnnotatedFor({"nullness"}) public class NotDirectoryException extends FileSystemException { @@ -44,7 +48,7 @@ public class NotDirectoryException * @param file * a string identifying the file or {@code null} if not known */ - public NotDirectoryException(String file) { + public NotDirectoryException(@Nullable String file) { super(file); } } diff --git a/src/java.base/share/classes/java/nio/file/NotLinkException.java b/src/java.base/share/classes/java/nio/file/NotLinkException.java index 02563d35a1129..cc8eb09aa1d64 100644 --- a/src/java.base/share/classes/java/nio/file/NotLinkException.java +++ b/src/java.base/share/classes/java/nio/file/NotLinkException.java @@ -25,6 +25,9 @@ package java.nio.file; +import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.framework.qual.AnnotatedFor; + /** * Checked exception thrown when a file system operation fails because a file * is not a symbolic link. @@ -32,6 +35,7 @@ * @since 1.7 */ +@AnnotatedFor({"nullness"}) public class NotLinkException extends FileSystemException { @@ -44,7 +48,7 @@ public class NotLinkException * @param file * a string identifying the file or {@code null} if not known */ - public NotLinkException(String file) { + public NotLinkException(@Nullable String file) { super(file); } @@ -58,7 +62,7 @@ public NotLinkException(String file) { * @param reason * a reason message with additional information or {@code null} */ - public NotLinkException(String file, String other, String reason) { + public NotLinkException(@Nullable String file, @Nullable String other, @Nullable String reason) { super(file, other, reason); } } diff --git a/src/java.base/share/classes/java/nio/file/ProviderMismatchException.java b/src/java.base/share/classes/java/nio/file/ProviderMismatchException.java index 70c1fad64abc4..78d9d0cb40b80 100644 --- a/src/java.base/share/classes/java/nio/file/ProviderMismatchException.java +++ b/src/java.base/share/classes/java/nio/file/ProviderMismatchException.java @@ -25,6 +25,9 @@ package java.nio.file; +import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.framework.qual.AnnotatedFor; + /** * Unchecked exception thrown when an attempt is made to invoke a method on an * object created by one file system provider with a parameter created by a @@ -32,6 +35,7 @@ * * @since 1.7 */ +@AnnotatedFor({"nullness"}) public class ProviderMismatchException extends java.lang.IllegalArgumentException { @@ -50,7 +54,7 @@ public ProviderMismatchException() { * @param msg * the detail message */ - public ProviderMismatchException(String msg) { + public ProviderMismatchException(@Nullable String msg) { super(msg); } } diff --git a/src/java.base/share/classes/java/nio/file/ProviderNotFoundException.java b/src/java.base/share/classes/java/nio/file/ProviderNotFoundException.java index 804f4996de244..192eae1f802d9 100644 --- a/src/java.base/share/classes/java/nio/file/ProviderNotFoundException.java +++ b/src/java.base/share/classes/java/nio/file/ProviderNotFoundException.java @@ -25,12 +25,16 @@ package java.nio.file; +import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.framework.qual.AnnotatedFor; + /** * Runtime exception thrown when a provider of the required type cannot be found. * * @since 1.7 */ +@AnnotatedFor({"nullness"}) public class ProviderNotFoundException extends RuntimeException { @@ -49,7 +53,7 @@ public ProviderNotFoundException() { * @param msg * the detail message */ - public ProviderNotFoundException(String msg) { + public ProviderNotFoundException(@Nullable String msg) { super(msg); } } diff --git a/src/java.base/share/classes/java/nio/file/ReadOnlyFileSystemException.java b/src/java.base/share/classes/java/nio/file/ReadOnlyFileSystemException.java index d187ef96b68e5..4284144164f2e 100644 --- a/src/java.base/share/classes/java/nio/file/ReadOnlyFileSystemException.java +++ b/src/java.base/share/classes/java/nio/file/ReadOnlyFileSystemException.java @@ -25,6 +25,8 @@ package java.nio.file; +import org.checkerframework.framework.qual.AnnotatedFor; + /** * Unchecked exception thrown when an attempt is made to update an object * associated with a {@link FileSystem#isReadOnly() read-only} {@code FileSystem}. @@ -32,6 +34,7 @@ * @since 1.7 */ +@AnnotatedFor({"nullness"}) public class ReadOnlyFileSystemException extends UnsupportedOperationException { diff --git a/src/java.base/share/classes/java/util/concurrent/BrokenBarrierException.java b/src/java.base/share/classes/java/util/concurrent/BrokenBarrierException.java index 11f126e015ad4..fb1e2fa1a979b 100644 --- a/src/java.base/share/classes/java/util/concurrent/BrokenBarrierException.java +++ b/src/java.base/share/classes/java/util/concurrent/BrokenBarrierException.java @@ -35,6 +35,9 @@ package java.util.concurrent; +import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.framework.qual.AnnotatedFor; + /** * Exception thrown when a thread tries to wait upon a barrier that is * in a broken state, or which enters the broken state while the thread @@ -45,6 +48,7 @@ * @since 1.5 * @author Doug Lea */ +@AnnotatedFor({"nullness"}) public class BrokenBarrierException extends Exception { private static final long serialVersionUID = 7117394618823254244L; @@ -60,7 +64,7 @@ public BrokenBarrierException() {} * * @param message the detail message */ - public BrokenBarrierException(String message) { + public BrokenBarrierException(@Nullable String message) { super(message); } } diff --git a/src/java.base/share/classes/java/util/concurrent/CompletionException.java b/src/java.base/share/classes/java/util/concurrent/CompletionException.java index 2a3cfc56adf2a..8a07647581551 100644 --- a/src/java.base/share/classes/java/util/concurrent/CompletionException.java +++ b/src/java.base/share/classes/java/util/concurrent/CompletionException.java @@ -35,6 +35,9 @@ package java.util.concurrent; +import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.framework.qual.AnnotatedFor; + /** * Exception thrown when an error or other exception is encountered * in the course of completing a result or task. @@ -42,6 +45,7 @@ * @since 1.8 * @author Doug Lea */ +@AnnotatedFor({"nullness"}) public class CompletionException extends RuntimeException { private static final long serialVersionUID = 7830266012832686185L; @@ -59,7 +63,7 @@ protected CompletionException() { } * * @param message the detail message */ - protected CompletionException(String message) { + protected CompletionException(@Nullable String message) { super(message); } @@ -71,7 +75,7 @@ protected CompletionException(String message) { * @param cause the cause (which is saved for later retrieval by the * {@link #getCause()} method) */ - public CompletionException(String message, Throwable cause) { + public CompletionException(@Nullable String message, @Nullable Throwable cause) { super(message, cause); } @@ -84,7 +88,7 @@ public CompletionException(String message, Throwable cause) { * @param cause the cause (which is saved for later retrieval by the * {@link #getCause()} method) */ - public CompletionException(Throwable cause) { + public CompletionException(@Nullable Throwable cause) { super(cause); } } diff --git a/src/java.base/share/classes/java/util/concurrent/RejectedExecutionException.java b/src/java.base/share/classes/java/util/concurrent/RejectedExecutionException.java index 87feef4951356..8529b89af114d 100644 --- a/src/java.base/share/classes/java/util/concurrent/RejectedExecutionException.java +++ b/src/java.base/share/classes/java/util/concurrent/RejectedExecutionException.java @@ -35,6 +35,9 @@ package java.util.concurrent; +import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.framework.qual.AnnotatedFor; + /** * Exception thrown by an {@link Executor} when a task cannot be * accepted for execution. @@ -42,6 +45,7 @@ * @since 1.5 * @author Doug Lea */ +@AnnotatedFor({"nullness"}) public class RejectedExecutionException extends RuntimeException { private static final long serialVersionUID = -375805702767069545L; @@ -60,7 +64,7 @@ public RejectedExecutionException() { } * * @param message the detail message */ - public RejectedExecutionException(String message) { + public RejectedExecutionException(@Nullable String message) { super(message); } @@ -72,7 +76,7 @@ public RejectedExecutionException(String message) { * @param cause the cause (which is saved for later retrieval by the * {@link #getCause()} method) */ - public RejectedExecutionException(String message, Throwable cause) { + public RejectedExecutionException(@Nullable String message, @Nullable Throwable cause) { super(message, cause); } @@ -85,7 +89,7 @@ public RejectedExecutionException(String message, Throwable cause) { * @param cause the cause (which is saved for later retrieval by the * {@link #getCause()} method) */ - public RejectedExecutionException(Throwable cause) { + public RejectedExecutionException(@Nullable Throwable cause) { super(cause); } }