xref: /aosp_15_r20/tools/metalava/stub-annotations/README.md (revision 115816f9299ab6ddd6b9673b81f34e707f6bacab)
1*115816f9SAndroid Build Coastguard WorkerStub Annotations
2*115816f9SAndroid Build Coastguard Worker
3*115816f9SAndroid Build Coastguard WorkerThe annotations in these packages are used to compile
4*115816f9SAndroid Build Coastguard Workerthe stubs. They are mostly identical to the annotations
5*115816f9SAndroid Build Coastguard Workerin the support library, but
6*115816f9SAndroid Build Coastguard Worker
7*115816f9SAndroid Build Coastguard Worker(1) There are some annotations here which are not in
8*115816f9SAndroid Build Coastguard Worker   the support library, such as @RecentlyNullable and
9*115816f9SAndroid Build Coastguard Worker   @RecentlyNonNull. These are used *only* in the stubs
10*115816f9SAndroid Build Coastguard Worker   to automatically mark code as recently annotated
11*115816f9SAndroid Build Coastguard Worker   with null/non-null. We do *not* want these annotations
12*115816f9SAndroid Build Coastguard Worker   in the source code; the recent-ness is computed at
13*115816f9SAndroid Build Coastguard Worker   build time and injected into the stubs in place
14*115816f9SAndroid Build Coastguard Worker   of the normal null annotations.
15*115816f9SAndroid Build Coastguard Worker
16*115816f9SAndroid Build Coastguard Worker(2) There are some annotations in the support library
17*115816f9SAndroid Build Coastguard Worker   that do not apply here, such as @Keep,
18*115816f9SAndroid Build Coastguard Worker   @VisibleForTesting, etc.
19*115816f9SAndroid Build Coastguard Worker
20*115816f9SAndroid Build Coastguard Worker(3) Only class retention annotations are interesting for
21*115816f9SAndroid Build Coastguard Worker   the stubs; that means for example that we don't
22*115816f9SAndroid Build Coastguard Worker   include @IntDef and @StringDef.
23*115816f9SAndroid Build Coastguard Worker
24*115816f9SAndroid Build Coastguard Worker(4) We've tweaked the retention of some of the support
25*115816f9SAndroid Build Coastguard Worker   library annotations; some of them were accidentally
26*115816f9SAndroid Build Coastguard Worker   source retention, and here they are class retention.
27*115816f9SAndroid Build Coastguard Worker
28*115816f9SAndroid Build Coastguard Worker(5) We've tweaked the nullness annotations to include
29*115816f9SAndroid Build Coastguard Worker   TYPE_PARAMETER and TYPE_USE targets, and removed
30*115816f9SAndroid Build Coastguard Worker   package, local variable, annotation type, etc.
31*115816f9SAndroid Build Coastguard Worker
32*115816f9SAndroid Build Coastguard Worker(6) There are some other differences; for example, the
33*115816f9SAndroid Build Coastguard Worker   @RequiresPermission annotation here has an extra
34*115816f9SAndroid Build Coastguard Worker   "apis" field used for merged historical annotations
35*115816f9SAndroid Build Coastguard Worker   to express the applicable API range.
36*115816f9SAndroid Build Coastguard Worker
37*115816f9SAndroid Build Coastguard WorkerEssentially, this is a curated list of exactly the
38*115816f9SAndroid Build Coastguard Workerset of annotations we allow injected into the stubs.
39*115816f9SAndroid Build Coastguard Worker
40