How do you use Java 1.6 Annotation Processing to perform compile time weaving?

前端 未结 4 1580
滥情空心
滥情空心 2020-12-18 02:57

I have created an annotation, applied it to a DTO and written a Java 1.6 style annotationProcessor. I can see how to have the annotationProcessor write a new source file, w

4条回答
  •  轮回少年
    2020-12-18 03:27

    By design, the annotation processing facility does not allow direct modification of the source code being processed. However, one can generate subclasses of the type being processed or the superclass of the type being processed. With some planning, this does allow some of the effect of modifying the type in question. I've written up an example of how this can fit together; see this blog entry for a more detailed explanation and some sample code.

提交回复
热议问题