import java.lang.annotation.*;
import java.lang.reflect.*;
@Retention(RetentionPolicy.RUNTIME)
@interface MyMarker { }
publicclass Marker {
// Annotate a method using a marker.
// Notice that no ( ) is needed.
@MyMarker
publicstaticvoid myMeth() {
Marker ob = new Marker();
try {
Method m = ob.getClass().getMethod("myMeth");
// Determine if the annotation is present.
if(m.isAnnotationPresent(MyMarker.class))
System.out.println("MyMarker is present.");
} catch (NoSuchMethodException exc) {
System.out.println("Method Not Found.");
}
}
publicstaticvoid main(String args[]) {
myMeth();
}
}