I am working on annotations and I need to have compiler time error when below code is encountered
public void myMethod(@myAnn Object[] ob) {
.
.
}
Compiler error should not be thrown with below code
public void myMethod(@myAnn Object ob) {
.
.
}
i want type should be Object
and not Object[]
I believe this is kind of type checking.Is there a way i can achieve this..reading at some other posts and JSR's i came to know this is something which is not allowed for annotations(I might be wrong hence i posted this q).
check for annotation type and make sure it's Object.class
like below code
if (annotation.annotationType().equals(java.lang.Object.class)){}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.