java - What's the conception behind: Type - Element - Mirror -


I am working with the annotation processing of Java 6, i.e. javax.annotation.processing (No APT of Java 5).

I wonder what is the transitional difference between different element , type , and mirror class is as it is to me Actually do not understand, this is an annotation processor is difficult to program efficiently, among these methods 'convert' in different ways, but I am not sure what I am doing while using them.

For example, let me know AnnotationMirror . When I call getAnnotationType () , I get an example of declared type (for whatever reason TypeMirror applies).
So I can call asElement () on this and get an example of Element .
What happened?

type of object javax.lang.model.element.AnnotationMirror your code Represents an annotation in

The declared type annotation class represents.

Its element is the general category (see for more information on that topic) Element can be a generic version of a class, such as list , where the declared type of parametric version Is, for example list & lt; String & gt; . Although I'm not sure whether it is possible to use Generation Generation Annotation classes and thus the distinction between that context may be inconsistent. For example, tell you that you have the following JUnit4 method:

  @Test (expected = MyException.class) Public zero myTest () {// do some tests on some classes. ..}  

represents annotation mirror @Test (expected = NullPointerException.class) . The declared type is org.junit.Test class. The element is more or less similar because there is no generic involved in it.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -