1 /* 2 * Copyright (C) 2018 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 com.android.tv.common.annotation; 18 19 import java.lang.annotation.ElementType; 20 import java.lang.annotation.Target; 21 22 /** 23 * Annotation used for marking methods and fields that are called from native 24 * code. Useful for keeping components that would otherwise be removed by 25 * Proguard. Use the value parameter to mention a file that calls this method. 26 * 27 * Note that adding this annotation to a method is not enough to guarantee that 28 * it is kept - either its class must be referenced elsewhere in the program, or 29 * the class must be annotated with this as well. 30 * 31 * Usage example:<br /> 32 * <pre>{@code 33 * @UsedByNative("NativeCrashHandler.cpp") 34 * public static void reportCrash(int signal, int code, int address) { 35 * ... 36 * } 37 * </pre> 38 * 39 */ 40 @Target({ElementType.METHOD, ElementType.FIELD, ElementType.TYPE, ElementType.CONSTRUCTOR}) 41 public @interface UsedByNative { value()42 String value(); 43 } 44