Annotate java.io.PrintWriter.
You can see the source files with the annotations in
https://android-review.googlesource.com/c/platform/libcore/+/701254
(which obviously is not intended for submission). The .jaif changes
here were copy-and-pasted from the results of running the
extract-annotations tool on those sources.
Most of this is straightforward.
The constructors mostly don't actually throw NPE if you pass a null to
them, but you do get a useless PrintWriter back, so it seems sensible
to annotate those as @NonNull.
You can pass a null array to the printf-style methods with something
like this: printf("message", (Object[]) null). The javadoc doesn't
specify what happens if you try. The implementation seems to accept
it. However, without a guarantee, it seems safer to mark that argument
as @NonNull. It's a very odd thing to write, anyway. The contents of
the array/varargs are @Nullable since it is legal to write
e.g. printf("this is %s", null) which passes a non-null array
containing a null object.
Test: make docs
Bug: 64930165
(cherry picked from commit df047a2dcf17fc2841d0f8aaed3094cf6e13940c)
Change-Id: Ia23c9176c386ec8630d642c6fb48bd5d03b652c8
Merged-In: I2d2788714a2df24b253490c83dd0f8b4316feef9
diff --git a/annotated_java_files.bp b/annotated_java_files.bp
index a4e17ac..77a2c6e 100644
--- a/annotated_java_files.bp
+++ b/annotated_java_files.bp
@@ -3,6 +3,7 @@
name: "annotated_ojluni_files",
export_to_make_var: "annotated_ojluni_files",
srcs: [
+ "ojluni/src/main/java/java/io/PrintWriter.java",
"ojluni/src/main/java/java/lang/Appendable.java",
"ojluni/src/main/java/java/lang/Boolean.java",
"ojluni/src/main/java/java/lang/Byte.java",
diff --git a/annotations/ojluni.jaif b/annotations/ojluni.jaif
index 1e6971a..a0bdabe 100644
--- a/annotations/ojluni.jaif
+++ b/annotations/ojluni.jaif
@@ -38,6 +38,176 @@
int from
int to
+package java.io:
+class PrintWriter:
+
+ method <init>(Ljava/io/Writer;)V:
+ return:
+ parameter #0:
+ type: @libcore.util.NonNull
+
+ method <init>(Ljava/io/Writer;Z)V:
+ return:
+ parameter #0:
+ type: @libcore.util.NonNull
+
+ method <init>(Ljava/io/OutputStream;)V:
+ return:
+ parameter #0:
+ type: @libcore.util.NonNull
+
+ method <init>(Ljava/io/OutputStream;Z)V:
+ return:
+ parameter #0:
+ type: @libcore.util.NonNull
+
+ method <init>(Ljava/lang/String;)V:
+ return:
+ parameter #0:
+ type: @libcore.util.NonNull
+
+ method <init>(Ljava/nio/charset/Charset;Ljava/io/File;)V:
+ return:
+
+ method <init>(Ljava/lang/String;Ljava/lang/String;)V:
+ return:
+ parameter #0:
+ type: @libcore.util.NonNull
+ parameter #1:
+ type: @libcore.util.NonNull
+
+ method <init>(Ljava/io/File;)V:
+ return:
+ parameter #0:
+ type: @libcore.util.NonNull
+
+ method <init>(Ljava/io/File;Ljava/lang/String;)V:
+ return:
+ parameter #0:
+ type: @libcore.util.NonNull
+ parameter #1:
+ type: @libcore.util.NonNull
+
+ method write([CII)V:
+ return:
+ parameter #0:
+ type: @libcore.util.NonNull
+
+ method write([C)V:
+ return:
+ parameter #0:
+ type: @libcore.util.NonNull
+
+ method write(Ljava/lang/String;II)V:
+ return:
+ parameter #0:
+ type: @libcore.util.NonNull
+
+ method write(Ljava/lang/String;)V:
+ return:
+ parameter #0:
+ type: @libcore.util.NonNull
+
+ method print([C)V:
+ return:
+ parameter #0:
+ type: @libcore.util.NonNull
+
+ method print(Ljava/lang/String;)V:
+ return:
+ parameter #0:
+ type: @libcore.util.Nullable
+
+ method print(Ljava/lang/Object;)V:
+ return:
+ parameter #0:
+ type: @libcore.util.Nullable
+
+ method println(Ljava/lang/String;)V:
+ return:
+ parameter #0:
+ type: @libcore.util.Nullable
+
+ method println(Ljava/lang/Object;)V:
+ return:
+ parameter #0:
+ type: @libcore.util.Nullable
+
+ method printf(Ljava/lang/String;[Ljava/lang/Object;)Ljava/io/PrintWriter;:
+ return: @libcore.util.NonNull
+ parameter #0:
+ type: @libcore.util.NonNull
+ parameter #1:
+ type: @libcore.util.NonNull
+ inner-type 0, 0: @libcore.util.Nullable
+
+ method printf(Ljava/util/Locale;Ljava/lang/String;[Ljava/lang/Object;)Ljava/io/PrintWriter;:
+ return: @libcore.util.NonNull
+ parameter #0:
+ type: @libcore.util.Nullable
+ parameter #1:
+ type: @libcore.util.NonNull
+ parameter #2:
+ type: @libcore.util.NonNull
+ inner-type 0, 0: @libcore.util.Nullable
+
+ method format(Ljava/lang/String;[Ljava/lang/Object;)Ljava/io/PrintWriter;:
+ return: @libcore.util.NonNull
+ parameter #0:
+ type: @libcore.util.NonNull
+ parameter #1:
+ type: @libcore.util.NonNull
+ inner-type 0, 0: @libcore.util.Nullable
+
+ method format(Ljava/util/Locale;Ljava/lang/String;[Ljava/lang/Object;)Ljava/io/PrintWriter;:
+ return: @libcore.util.NonNull
+ parameter #0:
+ type: @libcore.util.Nullable
+ parameter #1:
+ type: @libcore.util.NonNull
+ parameter #2:
+ type: @libcore.util.NonNull
+ inner-type 0, 0: @libcore.util.Nullable
+
+ method append(Ljava/lang/CharSequence;)Ljava/io/PrintWriter;:
+ return: @libcore.util.NonNull
+ parameter #0:
+ type: @libcore.util.Nullable
+
+ method append(Ljava/lang/CharSequence;II)Ljava/io/PrintWriter;:
+ return: @libcore.util.NonNull
+ parameter #0:
+ type: @libcore.util.Nullable
+
+ method append(C)Ljava/io/PrintWriter;:
+ return: @libcore.util.NonNull
+
+ method append(C)Ljava/io/Writer;:
+ return: @libcore.util.NonNull
+
+ method append(Ljava/lang/CharSequence;II)Ljava/io/Writer;:
+ return: @libcore.util.NonNull
+ parameter #0:
+ type: @libcore.util.Nullable
+
+ method append(Ljava/lang/CharSequence;)Ljava/io/Writer;:
+ return: @libcore.util.NonNull
+ parameter #0:
+ type: @libcore.util.Nullable
+
+ method append(C)Ljava/lang/Appendable;:
+ return: @libcore.util.NonNull
+
+ method append(Ljava/lang/CharSequence;II)Ljava/lang/Appendable;:
+ return: @libcore.util.NonNull
+ parameter #0:
+ type: @libcore.util.Nullable
+
+ method append(Ljava/lang/CharSequence;)Ljava/lang/Appendable;:
+ return: @libcore.util.NonNull
+ parameter #0:
+ type: @libcore.util.Nullable
+
package java.lang:
class Appendable:
method append(Ljava/lang/CharSequence;)Ljava/lang/Appendable;: