001/* 002 * Copyright 2017 The Error Prone Authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package com.google.errorprone.annotations; 017 018import static java.lang.annotation.ElementType.METHOD; 019import static java.lang.annotation.RetentionPolicy.SOURCE; 020 021import java.lang.annotation.Documented; 022import java.lang.annotation.Retention; 023import java.lang.annotation.Target; 024 025/** 026 * Indicates that any concrete method that overrides the annotated method, directly or indirectly, 027 * must invoke {@code super.theAnnotatedMethod(...)} at some point. This does not necessarily 028 * require an <i>unconditional</i> call; any matching call appearing directly within the method body 029 * (not inside an intervening class or lambda expression) is acceptable. 030 * 031 * <p>If the overriding method is itself overridable, applying this annotation to that method is 032 * technically redundant, but may be helpful to readers. 033 * 034 * <p><b>Preferred:</b> usually, a better solution is to make the method {@code final}, and have its 035 * implementation delegate to a second concrete method which <i>is</i> overridable (or to a function 036 * object which subclasses can specify). "Mandatory" statements remain in the final method while 037 * "optional" code moves out. This is the only way to make sure the statements will be executed 038 * unconditionally. 039 */ 040@Documented 041@Target(METHOD) 042@Retention(SOURCE) 043public @interface OverridingMethodsMustInvokeSuper {}