From bf63f941a095492067bf2faa7f9aceadfc60c86a Mon Sep 17 00:00:00 2001 From: Anton Hansson Date: Wed, 20 May 2020 12:06:23 +0100 Subject: [PATCH] Remove nullablility annotations from module-lib They were added to workaround the problem of package-private versions being added to the stubs, which prevented use of the annotations from mainline modules. Having them in the API leads to a different problem -- this version of the nullability annotations have SOURCE retention. However in the stubs build we want to have CLASS retention, so that kotlin can make use of their presence. This is arguably a much cleaner fix, since having a source-retention annotation doesn't really make much sense. Bug: 157010342 Test: m Change-Id: Id78f00da5b6af2930224a82faa24cb8235362521 --- StubLibraries.bp | 7 +++++-- api/module-lib-current.txt | 10 ---------- core/java/android/annotation/NonNull.java | 3 --- core/java/android/annotation/Nullable.java | 3 --- non-updatable-api/module-lib-current.txt | 10 ---------- 5 files changed, 5 insertions(+), 28 deletions(-) diff --git a/StubLibraries.bp b/StubLibraries.bp index e211bf32ee141..48c598fafda3d 100644 --- a/StubLibraries.bp +++ b/StubLibraries.bp @@ -310,8 +310,6 @@ java_defaults { name: "android_defaults_stubs_current", libs: [ "stub-annotations" ], static_libs: [ - "private-stub-annotations-jar", - // License notices from art module "art-notices-for-framework-stubs-jar", ], @@ -329,6 +327,7 @@ java_defaults { java_library_static { name: "android_monolith_stubs_current", srcs: [ ":api-stubs-docs" ], + static_libs: [ "private-stub-annotations-jar" ], defaults: ["android_defaults_stubs_current"], } @@ -345,6 +344,7 @@ java_library_static { "framework-statsd-stubs-publicapi", "framework-tethering-stubs-publicapi", "framework-wifi-stubs-publicapi", + "private-stub-annotations-jar", ], defaults: ["android_defaults_stubs_current"], } @@ -358,6 +358,7 @@ java_library_static { java_library_static { name: "android_system_monolith_stubs_current", srcs: [ ":system-api-stubs-docs" ], + static_libs: [ "private-stub-annotations-jar" ], defaults: ["android_defaults_stubs_current"], } @@ -375,6 +376,7 @@ java_library_static { "framework-statsd-stubs-systemapi", "framework-tethering-stubs-systemapi", "framework-wifi-stubs-systemapi", + "private-stub-annotations-jar", ], defaults: ["android_defaults_stubs_current"], } @@ -388,6 +390,7 @@ java_library_static { java_library_static { name: "android_test_stubs_current", srcs: [ ":test-api-stubs-docs" ], + static_libs: [ "private-stub-annotations-jar" ], defaults: ["android_defaults_stubs_current"], } diff --git a/api/module-lib-current.txt b/api/module-lib-current.txt index b505ce9457c0a..1afe4493e33c0 100644 --- a/api/module-lib-current.txt +++ b/api/module-lib-current.txt @@ -1,14 +1,4 @@ // Signature format: 2.0 -package android.annotation { - - @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.SOURCE) @java.lang.annotation.Target({java.lang.annotation.ElementType.METHOD, java.lang.annotation.ElementType.PARAMETER, java.lang.annotation.ElementType.FIELD}) public @interface NonNull { - } - - @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.SOURCE) @java.lang.annotation.Target({java.lang.annotation.ElementType.METHOD, java.lang.annotation.ElementType.PARAMETER, java.lang.annotation.ElementType.FIELD}) public @interface Nullable { - } - -} - package android.content.rollback { public class RollbackManagerFrameworkInitializer { diff --git a/core/java/android/annotation/NonNull.java b/core/java/android/annotation/NonNull.java index c5aff9d6794e9..20472bacf6ad5 100644 --- a/core/java/android/annotation/NonNull.java +++ b/core/java/android/annotation/NonNull.java @@ -20,8 +20,6 @@ import static java.lang.annotation.ElementType.METHOD; import static java.lang.annotation.ElementType.PARAMETER; import static java.lang.annotation.RetentionPolicy.SOURCE; -import android.annotation.SystemApi.Client; - import java.lang.annotation.Retention; import java.lang.annotation.Target; @@ -36,6 +34,5 @@ import java.lang.annotation.Target; */ @Retention(SOURCE) @Target({METHOD, PARAMETER, FIELD}) -@SystemApi(client = Client.MODULE_LIBRARIES) public @interface NonNull { } diff --git a/core/java/android/annotation/Nullable.java b/core/java/android/annotation/Nullable.java index 2fcddfab93758..b8473e750c954 100644 --- a/core/java/android/annotation/Nullable.java +++ b/core/java/android/annotation/Nullable.java @@ -20,8 +20,6 @@ import static java.lang.annotation.ElementType.METHOD; import static java.lang.annotation.ElementType.PARAMETER; import static java.lang.annotation.RetentionPolicy.SOURCE; -import android.annotation.SystemApi.Client; - import java.lang.annotation.Retention; import java.lang.annotation.Target; @@ -43,6 +41,5 @@ import java.lang.annotation.Target; */ @Retention(SOURCE) @Target({METHOD, PARAMETER, FIELD}) -@SystemApi(client = Client.MODULE_LIBRARIES) public @interface Nullable { } diff --git a/non-updatable-api/module-lib-current.txt b/non-updatable-api/module-lib-current.txt index c085cadcc69bf..c8406f199eddb 100644 --- a/non-updatable-api/module-lib-current.txt +++ b/non-updatable-api/module-lib-current.txt @@ -1,14 +1,4 @@ // Signature format: 2.0 -package android.annotation { - - @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.SOURCE) @java.lang.annotation.Target({java.lang.annotation.ElementType.METHOD, java.lang.annotation.ElementType.PARAMETER, java.lang.annotation.ElementType.FIELD}) public @interface NonNull { - } - - @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.SOURCE) @java.lang.annotation.Target({java.lang.annotation.ElementType.METHOD, java.lang.annotation.ElementType.PARAMETER, java.lang.annotation.ElementType.FIELD}) public @interface Nullable { - } - -} - package android.content.rollback { public class RollbackManagerFrameworkInitializer {