1

According to the class ElementType in the API, you can annotate local variables and method parameters.

How is that done?

2
  • 2
    remember that "An annotation on a local variable declaration is never retained in the binary representation." Commented Sep 2, 2009 at 11:51
  • @IAdapter Not even with RetentionPolicy.RUNTIME? Commented Jun 28, 2023 at 19:47

1 Answer 1

6

Just the usual way:

void method(@SomeAttr int param){
    @SomeAttr 
    int local = param * 2;
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.