Debian Codegraph @

src/com/google/errorprone/annotations/OverridingMethodsMustInvokeSuper.java

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
•1 /*
2 * Copyright 2017 The Error Prone Authors.
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 com.google.errorprone.annotations;
17
18 import static java.lang.annotation.ElementType.METHOD;
19 import static java.lang.annotation.RetentionPolicy.CLASS;
20
21 import java.lang.annotation.Documented;
22 import java.lang.annotation.Retention;
23 import java.lang.annotation.Target;
24
25 /**
26 * Indicates that any concrete method that overrides the annotated method, directly or indirectly,
27 * must invoke {@code super.theAnnotatedMethod(...)} at some point. This does not necessarily
28 * require an <i>unconditional</i> call; any matching call appearing directly within the method body
29 * (not inside an intervening class or lambda expression) is acceptable.
30 *
31 * <p>If the overriding method is itself overridable, applying this annotation to that method is
32 * technically redundant, but may be helpful to readers.
33 *
34 * <p><b>Preferred:</b> usually, a better solution is to make the method {@code final}, and have its
35 * implementation delegate to a second concrete method which <i>is</i> overridable (or to a function
36 * object which subclasses can specify). "Mandatory" statements remain in the final method while
37 * "optional" code moves out. This is the only way to make sure the statements will be executed
38 * unconditionally.
39 */
40 @Documented
41 @Target(METHOD)
42 @Retention(CLASS)
43 public @interface OverridingMethodsMustInvokeSuper {}