正在进行Java(JavaX )注释处理。
假设有一种评论的方法:
@target(elementtype.method )。
public @ interfacemethodannotation { }
现在,我想使用带注释的方法来处理类型涵盖的所有方法:
接口my接口(
@MethodAnnotation
void f () )
}
classmyclassimplementsmyinterface {
override void f () /
}
@Inherited元注释在此似乎不合适:
notethatthismeta -注释类型pehasnoeffectiftheannotatedtypeisusedtoannotateanythingotherthanaclass。
另外,是否可以处理未被子类覆盖的继承类方法? 我喜欢这个:
class MyClass {
@MethodAnnotation
void f () }
}
classmysubclassextendsmyclass { }//
//oratleasttofindoutthatitdoesn ' t
//override the method
如何在AbstractProcessor中访问某种方法的覆盖方法?
为了实现这一点,我认为有必要找到eclosing类的子类,但还没有找到实现它的方法。
我认为可以使用upd:round environment.getrootelements () ),但还没有找到正确的方法。