Pregunta

I am writing an annotation processor and I need to instantiate a class being processed.

I am extracting some documentation based on the class and its annotations, and I'd like to run a method from this class and output the result in the generated documentation.

Unfortunately, when I try to instantiate it I have a ClassNotFoundException which seems logical to me as the processing happens before the compilation round.

I am currently writting an xml file that holds the documentation, maybe there is an annotation post-processor or something similar?

Do you have any idea of workaround?

¿Fue útil?

Solución

Well, definitely, we cannot access a class being processed because at the same time it is being compiled.

And there is no way to run the annotation processor after the compilation round.

Then I searched in maven and spot the phase: process-classes

It is executed just after the compilation succeed, so it is perfect for my needs. During this phase I execute a java class that reads the xml file I have generated during the annotation processing. At this point I can access everything !

HIH

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top