title: How to get the type of a field in an annotation processor?
body: <p>I'm trying to write an annotation to check if an object is immutable at runtime. In order to do so, I check if the class of the object is final and then if all its attributes are also final. And then, I want to check the same thing recursively for the type of each field if it's not a primitive type.</p>
  
  <p>Here a piece of code:</p>
  
  <pre><code>for (Element subElement : element.getEnclosedElements()) {
      if (subElement.getKind().isField()) {
          isFinal=false;
  
          for(Modifier modifier : subElement.getModifiers()) {
              if (modifier.equals(Modifier.FINAL)) {
                  isFinal=true;
                  break;
              }
          }
          if (!isFinal) {
              processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "Field "+element+" is not immutable because it is not final");
          } else {
              // Here I want to restart my method recursively
          }
      }
  }
  </code></pre>
  
  <p>How can I get my method to start all over again with the type of my field? How can I retrieve the type of the field, which is here a <a href="http://docs.oracle.com/javase/6/docs/api/javax/lang/model/element/Element.html" rel="nofollow"><code>javax.lang.model.element.Element</code></a>?</p>
  
  <p>Edit: I need the type as declared in the containing class, which needs to be a final class to avoid any kind of mutability.</p>