How can I retrieve the value of an annotation on the annotated method??
I have:
@myAnnotation(attribute1 = value1, attibute2 = value2)
public void myMethod()
{
//I want to get value1 here
}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Methodinstance.Something like:
You’ll need to catch / handle the appropriate exceptions, of course. The above assumes you are indeed retrieving method from the current class (replace
getClass()withClass.forName()otherwise) and the method in question is public (usegetDeclaredMethods()if that’s not the case)