5 Replies Latest reply: Jan 8, 2009 1:59 AM by 843793 RSS

    Is it possible to stop compiling process in annotations processing?

    843793
      Hi all.

      I'm doing annotations processing with javac.

      Is it possible to stop compilation if an error occurs during annotations processing?

      Thank you!
        • 1. Re: Is it possible to stop compiling process in annotations processing?
          843793
          francadaval wrote:
          Hi all.

          I'm doing annotations processing with javac.

          Is it possible to stop compilation if an error occurs during annotations processing?
          If you raise an error with the Messager:
          http://java.sun.com/javase/6/docs/api/javax/annotation/processing/Messager.html

          no class files will be generated. This is the recommended way to start winding things down; from the Processor class:

          "If a processor throws an uncaught exception, the tool may cease other active annotation processors. If a processor raises an error, the current round will run to completion and the subsequent round will indicate an error was raised. Since annotation processors are run in a cooperative environment, a processor should throw an uncaught exception only in situations where no error recovery or reporting is feasible."
          • 2. Re: Is it possible to stop compiling process in annotations processing?
            843793
            There is a very good example at this url for your issue : http://www.javaspecialists.eu/archive/Issue167.html
            • 3. Re: Is it possible to stop compiling process in annotations processing?
              843793
              Thank you for your answers.

              I've already done this but, althoug I send an error message, the compilation runs and class files are generated. I'm using Maven for projects management. I think it must be a problem with Maven compilation. I know annotations processor runs because System.out works but I can`t see error messages.
              • 4. Re: Is it possible to stop compiling process in annotations processing?
                608410
                francadaval wrote:
                Thank you for your answers.

                I've already done this but, althoug I send an error message,
                +
                I know annotations processor runs because System.out works but I can`t see error messages.
                Are you raising errors or not? You think you are, but you don't see them - so maybe you are not!

                Can you please post the code where you "send an error message"

                Bruce
                • 5. Re: Is it possible to stop compiling process in annotations processing?
                  843793
                  Yes, i'm sure i'm raising errors. Errors appear with direct compilation with javac. And other messages are sent with Messager class but no one can be seen with maven compilation.

                  I've located other users in diferent forums that have the same problem but nobody has the answer. I've subscribed to maven users mailing list to try to have an answer. If I found a solution i'll post it here.