I am playing with the idea of using local variable annotation to generate Resource Bundle file. So that the exception message are not hard coded and can be localzied. This approach allows developer to coded the message in one place (.java file) instead of jumping bewteeen resource bundle property file and java file.
Once I started, I realize I am not sure how to access Local Veriable annotation to do this. There are several potential approaches: but none of them seems work:
1. using Annotation Processing Tool (APT). In APT, the local variable is invisible. Sun stated "Annotations on local variables are invisible since the declaration hierarchy does not model program structure inside a method or constructor." on the APT website.
2. Using reflection or AOP doesn't work, as local variable annotation has only SOURCE Retention.
Is there a way of accessing local variable annotation in Java 5 ?