Migrate annotations of two ojluni classes to Java stubs.
This change migrates the first two classes' nullability annotations
from JAIF to Java stubs, as a proof of concept.
It is a noop in the resulting stubs, i.e. it does not change
metalava-api-stubs-docs.jar.
This change makes it obvious that Iterable is missing some
annotations. They will be added later (to make this change a pure
refactoring).
This adopts a convention for the naming of the annotated stub files
which is intended to (a) make it obvious which 'real' source files
they correspond to, but (b) not risk anyone confusing the annotated
stub file and the real source file. (From a technical perspective, the
only requirement is that the file names end with .java.)
Bug: 111639530
Test: `make make metalava-api-stubs-docs`
Change-Id: I8ad322194a3818ac00416bc631325162228ed07c
diff --git a/JavaLibrary.bp b/JavaLibrary.bp
index 517cc05..21588e9 100644
--- a/JavaLibrary.bp
+++ b/JavaLibrary.bp
@@ -280,6 +280,12 @@
],
}
+// Make the annotated stubs in ojluni/annotations available to metalava:
+droiddoc_exported_dir {
+ name: "ojluni-annotated-stubs",
+ path: "ojluni/annotations",
+}
+
//
// Local droiddoc for faster libcore testing
//
diff --git a/annotated_java_files.bp b/annotated_java_files.bp
index 77a2c6e..ed99a3e 100644
--- a/annotated_java_files.bp
+++ b/annotated_java_files.bp
@@ -14,7 +14,6 @@
"ojluni/src/main/java/java/lang/Enum.java",
"ojluni/src/main/java/java/lang/Float.java",
"ojluni/src/main/java/java/lang/Integer.java",
- "ojluni/src/main/java/java/lang/Iterable.java",
"ojluni/src/main/java/java/lang/Long.java",
"ojluni/src/main/java/java/lang/Object.java",
"ojluni/src/main/java/java/lang/String.java",
@@ -41,7 +40,6 @@
"ojluni/src/main/java/java/lang/reflect/WildcardType.java",
"ojluni/src/main/java/java/util/ArrayList.java",
"ojluni/src/main/java/java/util/HashMap.java",
- "ojluni/src/main/java/java/util/Iterator.java",
"ojluni/src/main/java/java/util/List.java",
"ojluni/src/main/java/java/util/Map.java",
"ojluni/src/main/java/java/util/Set.java",
diff --git a/annotations/ojluni.jaif b/annotations/ojluni.jaif
index 995cc4e..1c2f9d5 100644
--- a/annotations/ojluni.jaif
+++ b/annotations/ojluni.jaif
@@ -453,11 +453,6 @@
method valueOf(Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/Enum;:
return: @libcore.util.NonNull
-class Iterable:
- // Always returns an instance
- method iterator()Ljava/util/Iterator;:
- return: @libcore.util.NonNull
-
class Integer:
method toString(II)Ljava/lang/String;:
// Always returns an instance
@@ -2432,17 +2427,6 @@
method clone()Ljava/lang/Object;:
return: @libcore.util.NonNull
-class Iterator:
-
- method next()Ljava/lang/Object;:
- return: @libcore.util.NullFromTypeParam
-
- method forEachRemaining(Ljava/util/function/Consumer;)V:
- return:
- parameter #0:
- type: @libcore.util.NonNull
- inner-type 3, 0,2, 0: @libcore.util.NullFromTypeParam
-
class List:
method contains(Ljava/lang/Object;)Z:
// May be null
diff --git a/ojluni/annotations/java/lang/Iterable.annotated.java b/ojluni/annotations/java/lang/Iterable.annotated.java
new file mode 100644
index 0000000..3c7b2b6
--- /dev/null
+++ b/ojluni/annotations/java/lang/Iterable.annotated.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.lang;
+
+import java.util.Iterator;
+import java.util.Spliterator;
+import java.util.function.Consumer;
+import libcore.annotation.NonNull;
+import libcore.annotation.NullFromTypeParam;
+
+public interface Iterable<T> {
+
+ public @NonNull Iterator<@NullFromTypeParam T> iterator();
+ public default void forEach(Consumer<? super T> action) { throw new RuntimeException("Stub!"); }
+ public default Spliterator<T> spliterator() { throw new RuntimeException("Stub!"); }
+}
diff --git a/ojluni/annotations/java/util/Iterator.annotated.java b/ojluni/annotations/java/util/Iterator.annotated.java
new file mode 100644
index 0000000..31775ac
--- /dev/null
+++ b/ojluni/annotations/java/util/Iterator.annotated.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package java.util;
+
+import java.util.function.Consumer;
+import libcore.annotation.NonNull;
+import libcore.annotation.NullFromTypeParam;
+
+public interface Iterator<E> {
+
+ public boolean hasNext();
+ public @NullFromTypeParam E next();
+ public default void remove() { throw new RuntimeException("Stub!"); }
+ public default void forEachRemaining(@NonNull Consumer<? super @NullFromTypeParam E> action) { throw new RuntimeException("Stub!"); }
+}
+
+