dalvik: Add @NeverCompile annotation for art

Methods annotated with @NeverCompile will not be compiled--this will be
useful for keeping debug methods from appearing in .odex files.

Bug: 197753440
Test: Checked that @NeverCompile annotations are retained while
      building, and result in methods not being compiled.
Change-Id: I7e5dd2dceb78410ea837e0e3e48b59745361da24
diff --git a/api/module-lib-current.txt b/api/module-lib-current.txt
index ce54d56..dd182f0 100644
--- a/api/module-lib-current.txt
+++ b/api/module-lib-current.txt
@@ -162,6 +162,9 @@
   @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.METHOD) public @interface FastNative {
   }
 
+  @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.METHOD) public @interface NeverCompile {
+  }
+
 }
 
 package dalvik.system {
diff --git a/dalvik/src/main/java/dalvik/annotation/optimization/NeverCompile.java b/dalvik/src/main/java/dalvik/annotation/optimization/NeverCompile.java
new file mode 100644
index 0000000..61fe622
--- /dev/null
+++ b/dalvik/src/main/java/dalvik/annotation/optimization/NeverCompile.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2021 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 dalvik.annotation.optimization;
+
+import static android.annotation.SystemApi.Client.MODULE_LIBRARIES;
+
+import android.annotation.SystemApi;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Indicates that an API should never be compiled.
+ *
+ * <p>
+ * NeverCompile can be used to annotate methods that should not be compiled and included in .odex
+ * files. Methods that are not called frequently, are never speed-critical, or are only used for
+ * debugging do not necessarily need to run quickly. Applying this annotation to prevent these
+ * methods from being compiled will return some size improvements in the .odex file that they would
+ * otherwise be included in.
+ * </p>
+ *
+ * <p>
+ * The <code>dumpPackageLPr</code> method in com.android.server.pm can be used as a concrete
+ * example. This is a debug method used to dump all of the information about a device's installed
+ * packages. When it is compiled, it is included in services.odex. Annotating this method with
+ * NeverCompile can be seen to reduce the size of services.odex by roughly 28KB.
+ * </p>
+ * @hide
+ */
+@SystemApi(client = MODULE_LIBRARIES)
+@Retention(RetentionPolicy.CLASS)
+@Target(ElementType.METHOD)
+public @interface NeverCompile {}
diff --git a/non_openjdk_java_files.bp b/non_openjdk_java_files.bp
index d7601bc..d773cfe 100755
--- a/non_openjdk_java_files.bp
+++ b/non_openjdk_java_files.bp
@@ -28,6 +28,7 @@
         "dalvik/src/main/java/dalvik/annotation/optimization/CriticalNative.java",
         "dalvik/src/main/java/dalvik/annotation/optimization/DeadReferenceSafe.java",
         "dalvik/src/main/java/dalvik/annotation/optimization/FastNative.java",
+        "dalvik/src/main/java/dalvik/annotation/optimization/NeverCompile.java",
         "dalvik/src/main/java/dalvik/annotation/optimization/ReachabilitySensitive.java",
         "dalvik/src/main/java/dalvik/bytecode/OpcodeInfo.java",
         "dalvik/src/main/java/dalvik/bytecode/Opcodes.java",