Can the Java – pluggable annotation processor API retrieve source code annotations?

I am using the pluggable annotation processing API with Java 6 to automatically create some deployment XML files Some of these XML files contain descriptions of objects The description always has the same content as the Javadoc associated with the class itself I can force the comment to be a field of the @ block comment, but this copies the information Is there any method to get the content of class / type annotation during annotation processing?

In this example, I want to get "a good description of my block" during annotation processing

/**
* A nice description of my block
**/
@Block
public class CustomBlock {
}

Solution

After I released so, I always seem to find the answer

For future reference, this is the solution

public class CustomAnnotationProcessor extends AbstractAnnotationProcessor
{
    public boolean process(...)
    {

        // use the protected member,processingEnv

        String comment = processingEnv.getElementUtils().getDocComment(anyElement);


    }
}
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>