summaryrefslogtreecommitdiff
path: root/stub-annotations/src/main/java/androidx/annotation/MainThread.java
diff options
context:
space:
mode:
authorTor Norbye <tnorbye@google.com>2018-05-20 19:30:56 -0700
committerTor Norbye <tnorbye@google.com>2018-05-21 18:15:55 -0700
commit5bda8555401bc13ef9009ad174274768302c7d9d (patch)
tree04fe864b09f72cac8389a4d01f7f377c9d65d5b8 /stub-annotations/src/main/java/androidx/annotation/MainThread.java
parentfcb3d99ad3fe17a266d066b28ceb6c526f7aa415 (diff)
Improvements to annotation extraction, doconly and nullness migration
This CL fixes a number of issses in metalava: (1) Support separate stub file generation for android.jar and for documentation stubs. The "--stubs" flag continues to create stubs intended for compilation into android.jar, and the new "--doc-stubs" flag generates stubs intended for documentation migration. Why are these separate, you ask? It turns out the stubs we compile for android.jar needs to be slightly different from those we generate documentation for. Here are some specific examples: (a) In the SDK stubs we'll use different nullness annotations for recently annotated elements than for elements that have been annotated for a while. This allows the Kotlin compiler to treat violations of these contracts as a warning instead of an error. In the documentation, however, we just want the normal @NonNull/@Nullable annotations to show up, not the specialized migration versions of these. (b) @doconly: Some elements, such as R.styleable, are marked with @doconly and should be present when running for example javadoc on the code, but should not be present in the actual SDK. (2) This CL updates the set of stub annotations that the stubs can be compiled with. These are in many cases nearly identical to the androidx.annotations in the support library, but with some notable changes, such as allowing type parameter and type use for the nullness annotations, switching to class retention for a few annotations, and removing some that don't apply. (3) This CL updates the nullness migration to the new scheme supported by Kotlin 1.2.50, and removes earlier handling for multiple stages of migration (@Newly<X> vs @Recently<X>). It also changes the annotation package handling from prefering android.support.annotation to androidx.annotation. There area also various fixes to the nullness coverage code which lets the reports be written to files, which more correctly accounts for static final primitive constants, etc. Finally, misc bug fixes I encountered. At this point, metalava can spit out stubs containing annotations that compile -- and which contain the right migration names for Kotlin. Bug: N/A Test: Unit tests included and updated Change-Id: I4915e199e2e14473df62206015461108bc58b962
Diffstat (limited to 'stub-annotations/src/main/java/androidx/annotation/MainThread.java')
-rw-r--r--stub-annotations/src/main/java/androidx/annotation/MainThread.java30
1 files changed, 30 insertions, 0 deletions
diff --git a/stub-annotations/src/main/java/androidx/annotation/MainThread.java b/stub-annotations/src/main/java/androidx/annotation/MainThread.java
new file mode 100644
index 0000000..d8a5e60
--- /dev/null
+++ b/stub-annotations/src/main/java/androidx/annotation/MainThread.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package androidx.annotation;
+
+import static java.lang.annotation.ElementType.CONSTRUCTOR;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.CLASS;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/** Stub only annotation. Do not use directly. */
+@Retention(CLASS)
+@Target({METHOD, CONSTRUCTOR, TYPE, PARAMETER})
+public @interface MainThread {}