1 /* 2 * Copyright (C) 2021 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package dalvik.annotation.optimization; 18 19 import static android.annotation.SystemApi.Client.MODULE_LIBRARIES; 20 21 import android.annotation.SystemApi; 22 23 import java.lang.annotation.ElementType; 24 import java.lang.annotation.Retention; 25 import java.lang.annotation.RetentionPolicy; 26 import java.lang.annotation.Target; 27 28 /** 29 * Indicates that an API should never be compiled. 30 * 31 * <p> 32 * NeverCompile can be used to annotate methods that should not be compiled and included in .odex 33 * files. Methods that are not called frequently, are never speed-critical, or are only used for 34 * debugging do not necessarily need to run quickly. Applying this annotation to prevent these 35 * methods from being compiled will return some size improvements in the .odex file that they would 36 * otherwise be included in. 37 * </p> 38 * 39 * <p> 40 * This annotation will have no effect when applied to native methods, as JNI stubs will still be 41 * compiled. In addition, it will not stop overriding methods from being compiled, so applying this 42 * annotation to abstract methods will not do anything. 43 * </p> 44 * 45 * <p> 46 * The <code>dumpPackageLPr</code> method in com.android.server.pm can be used as a concrete 47 * example. This is a debug method used to dump all of the information about a device's installed 48 * packages. When it is compiled, it is included in services.odex. Annotating this method with 49 * NeverCompile can be seen to reduce the size of services.odex by roughly 28KB. 50 * </p> 51 * @hide 52 */ 53 @SystemApi(client = MODULE_LIBRARIES) 54 @Retention(RetentionPolicy.CLASS) 55 @Target(ElementType.METHOD) 56 public @interface NeverCompile {} 57