【发布时间】:2019-03-12 10:56:42
【问题描述】:
我有一个接口 I 和一个抽象类 A ,我有我的自定义注释 MyAnnotation 应该将参数作为子类 A的S,现在在处理注释时我想调用具体类的方法S
public interface I{
void m1();
}
public abstract class A implements I {
public abstract void m1();
}
public @interface MyAnnotation {
public Class< ? extends A> ref();
public Class< ? super A> ref2();
}
public S extends A{
public void m1() {}
}
我正在注释方法,例如
@MyAnnotation(ref= new XX() ) or @MyAnnotation(ref= XX.class )
@MyAnnotation(ref= new yy() ) or @MyAnnotation(ref= yy.class )
无论哪个有效
//In spring aspect before processing I am getting method annotation and trying to call m1()
annotation.ref().m1() //Error
annotation.ref2().m1() //Error
【问题讨论】:
-
abstarct和public S extends A不正确
标签: java java-8 annotations