@Documented @Retention(value=RUNTIME) @Target(value=METHOD) public @interface MustInvokeOnOverride
Any method that overrides a method annotated
@MustInvokeOnOverride must also be annotated
@MustInvokeOnOverride unless it is declared to be
final or declared within a final class. It is a modeling
error if it is not.
It is a modeling error to place this annotation on a method declared to be final or declared within a final class
Activity class requires that "derived classes must call
through to the super class's implementation" for several methods. This
requirement can be documented with this annotation as shown below for the
onCreate method.
package android.app;
public class Activity extends ... {
@MustInvokeOnOverride
protected void onCreate(Bundle savedInstanceState) {
...
}
...
}
The below code shows a derived class, Earthquake, that correctly
invokes the onCreate method in its super class. Note that the
onCreate method in the Earthquake class is not annotated
@MustInvokeOnOverride because the class is declared to be
final.
public final class Earthquake extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
...
}
@annotate tag.
public class Activity extends ... {
/**
* @annotate MustInvokeOnOverride
*/
protected void onCreate(Bundle savedInstanceState) {
...
}
...
}
Copyright © 2012 Surelogic, Inc.. All Rights Reserved.