• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023 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 package android.ravenwood.annotation;
17 
18 import static java.lang.annotation.ElementType.METHOD;
19 
20 import java.lang.annotation.Retention;
21 import java.lang.annotation.RetentionPolicy;
22 import java.lang.annotation.Target;
23 
24 /**
25  * Denotes that the annotated method is supported on Ravenwood, however the implementation
26  * will be replaced with the method suffixed with "$ravenwood".
27  * <p>
28  * Example:
29  * <pre>
30  *     @RavenwoodKeepPartialClass
31  *     public class Foo {
32  *         @RavenwoodReplace
33  *         public void doComplex() {
34  *             // This method implementation runs as-is on devices, but the
35  *             // implementation is replaced/substituted by the
36  *             // doComplex$ravenwood() method implementation under Ravenwood
37  *         }
38  *
39  *         private void doComplex$ravenwood() {
40  *             // This method implementation only runs under Ravenwood.
41  *             // The visibility of this replacement method does not need to match
42  *             // the original method, so it's recommended to always use
43  *             // private methods so that these methods won't be accidentally used
44  *             // by unexpected users.
45  *         }
46  *     }
47  * </pre>
48  *
49  * @hide
50  */
51 @Target({METHOD})
52 @Retention(RetentionPolicy.CLASS)
53 public @interface RavenwoodReplace {
54     /**
55      * One or more classes that aren't yet supported by Ravenwood, which is why this method is
56      * being replaced.
57      */
blockedBy()58     Class<?>[] blockedBy() default {};
59 
60     /**
61      * General free-form description of why this method is being replaced.
62      */
reason()63     String reason() default "";
64 
65     /**
66      * Tracking bug number, if any.
67      */
bug()68     long bug() default 0;
69 }
70