I have a class Book which has some annotations like @Override,@Before,@After.
How can I get those annotations using ICompilationUnit?
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.
Javadoc for IAnnotation states that:
“Annotations are obtained using IAnnotatable.getAnnotation(String).
Note that annotations are not children of their declaring element. To get a list of the annotations use IAnnotatable.getAnnotations().”
What’s an IAnnotatable? IField, ILocalVariable, IMethod, IPackageDeclaration, IType.
There are methods on ICompilationUnit for getting objects of those types.