[JSR308] Simple question regarding jsr308 compiler for local variable annotation processing

Chester Chen CChen at ascentmedia.com
Tue Dec 16 19:25:21 EST 2008


Hi, 
   
   I am interested in using JSR308 compiler to processing my local variable annotations. 
   
   for example, 

   public void myMethod() {
     String myValue = null;

     if (!testCondition(myTest))  {
         @ErrorMessage(messageFormat="this is annoation on local variable, value = {0} ";
         String errorCode = "EC_101";
         throw new MyException(errorCode, myValue);
     }
     else 
        doSomething();
   }


   It looks like JSR308 (later Java 7) will be able to do this. With JSR308 compiler, after the installation (replacing tools.jar will toos-jsr308.jar) in JDK 1.6.x; Would I be able to pick local variable annotation ?

   For example overwrite the ElementScanner6 class method

    /**
     * {@inheritDoc} This implementation scans the enclosed elements.
     *
     * @param e  the element to visit
     * @param p  a visitor-specified parameter
     * @return the result of scanning
     */
    public R visitVariable(VariableElement e, P p) {
	//print annotation here 
    }


Please advise. 

Thanks

Chester


   



More information about the JSR308 mailing list