自定义注解
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @
interface IgnoreAuth {
}
@Retention:注解的保留位置
@Retention(RetentionPolicy.SOURCE)
//注解仅存在于源码中,在
class字节码文件中不包含
@Retention(RetentionPolicy.CLASS)
// 默认的保留策略,注解会在
class字节码文件中存在,但运行时无法获得,
@Retention(RetentionPolicy.RUNTIME)
// 注解会在
class字节码文件中存在,在运行时可以通过反射获取到
@Target:注解的作用目标
@Target(ElementType.TYPE)
@Target(ElementType.FIELD)
@Target(ElementType.METHOD)
@Target(ElementType.PARAMETER)
@Target(ElementType.CONSTRUCTOR)
@Target(ElementType.LOCAL_VARIABLE)
@Target(ElementType.ANNOTATION_TYPE)
@Target(ElementType.PACKAGE)
@Document:说明该注解将被包含在javadoc中@Inherited:说明子类可以继承父类中的该注解@AnnatDemo注解 可以使用反射获取
public interface IClientProtocolEx extends IProtocol
Class ipt=IClientProtocalEx.
class;
Method[] mts=ipt.getMethod();
for(
Method mt:mts)