Is there a limit on the number of Java annotations on a field? I couldn’t find any information on that point.
Share
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.
No, there is nothing about a limit in the spec.
See here: http://docs.oracle.com/javase/specs/jls/se7/jls7.pdf
The only limit you encounter for java files in general are os-wide limits like max. file size on some filesystems or – in hardcore cases – the disk size. Some systems might have problems compiling or running a 100gb .java/.class file…
Do as you please. It’s just that it’s probably bad design. Keeping it bellow 10 is a good rule of thumb, I’d say.
Edit: It seems there is, after all, a limit. At least on runtime annotations on methods.
Not sure if this counts for fields too.
So, I guess the answer depends on the kind of annotations you want to add.
Nothing about that in the language spec though. I guess they didn’t really think someone would try it.