Merge "Add @DoNotInline annotation" into androidx-master-dev
diff --git a/annotation/annotation/api/current.txt b/annotation/annotation/api/current.txt
index 466cec5..3c5ed6b 100644
--- a/annotation/annotation/api/current.txt
+++ b/annotation/annotation/api/current.txt
@@ -61,6 +61,9 @@
field public static final int SP = 2; // 0x2
}
+ @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target({java.lang.annotation.ElementType.METHOD}) public @interface DoNotInline {
+ }
+
@java.lang.annotation.Documented @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target({java.lang.annotation.ElementType.METHOD, java.lang.annotation.ElementType.PARAMETER, java.lang.annotation.ElementType.FIELD, java.lang.annotation.ElementType.LOCAL_VARIABLE}) public @interface DrawableRes {
}
diff --git a/annotation/annotation/api/public_plus_experimental_current.txt b/annotation/annotation/api/public_plus_experimental_current.txt
index 466cec5..3c5ed6b 100644
--- a/annotation/annotation/api/public_plus_experimental_current.txt
+++ b/annotation/annotation/api/public_plus_experimental_current.txt
@@ -61,6 +61,9 @@
field public static final int SP = 2; // 0x2
}
+ @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target({java.lang.annotation.ElementType.METHOD}) public @interface DoNotInline {
+ }
+
@java.lang.annotation.Documented @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target({java.lang.annotation.ElementType.METHOD, java.lang.annotation.ElementType.PARAMETER, java.lang.annotation.ElementType.FIELD, java.lang.annotation.ElementType.LOCAL_VARIABLE}) public @interface DrawableRes {
}
diff --git a/annotation/annotation/api/restricted_current.txt b/annotation/annotation/api/restricted_current.txt
index 466cec5..3c5ed6b 100644
--- a/annotation/annotation/api/restricted_current.txt
+++ b/annotation/annotation/api/restricted_current.txt
@@ -61,6 +61,9 @@
field public static final int SP = 2; // 0x2
}
+ @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target({java.lang.annotation.ElementType.METHOD}) public @interface DoNotInline {
+ }
+
@java.lang.annotation.Documented @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target({java.lang.annotation.ElementType.METHOD, java.lang.annotation.ElementType.PARAMETER, java.lang.annotation.ElementType.FIELD, java.lang.annotation.ElementType.LOCAL_VARIABLE}) public @interface DrawableRes {
}
diff --git a/annotation/annotation/src/main/java/androidx/annotation/DoNotInline.java b/annotation/annotation/src/main/java/androidx/annotation/DoNotInline.java
new file mode 100644
index 0000000..3ae3fa4
--- /dev/null
+++ b/annotation/annotation/src/main/java/androidx/annotation/DoNotInline.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2020 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.METHOD;
+import static java.lang.annotation.RetentionPolicy.CLASS;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * Denotes that the annotated method should not be inlined when
+ * the code is optimized at build time. This is typically used
+ * to avoid inlining purposely out-of-line methods that are
+ * intended to be in separate classes.
+ * <p>
+ * Example:
+ * <pre><code>
+ * @DoNotInline
+ * public void foo() {
+ * ...
+ * }
+ * </code></pre>
+ */
+@Retention(CLASS)
+@Target({METHOD})
+public @interface DoNotInline {
+}
diff --git a/annotation/annotation/src/main/resources/META-INF/proguard/androidx-annotations.pro b/annotation/annotation/src/main/resources/META-INF/proguard/androidx-annotations.pro
index cd1cd53..4b58b5f 100644
--- a/annotation/annotation/src/main/resources/META-INF/proguard/androidx-annotations.pro
+++ b/annotation/annotation/src/main/resources/META-INF/proguard/androidx-annotations.pro
@@ -12,3 +12,7 @@
-keepclasseswithmembers class * {
@androidx.annotation.Keep <init>(...);
}
+
+-keepclassmembers,allowobfuscation class * {
+ @androidx.annotation.DoNotInline <methods>;
+}