viraptor
viraptor

Reputation: 34185

Running processor gives duplicate classes warning

After running javac with some processor selected, I get the proper source files generated. Unfortunately, every time I rerun the process I see warnings about duplicate class: com..... (one being processed).

This does not cause the ant task to fail, so it's not a real problem, but I'd be glad to get rid of the message. How can I do that?

I'm basically running:

JavaFileObject jfo = environment.getFiler().createSourceFile(somepackage + "." + myType.getSimpleName() + "Generated", myType);
Writer writer = jfo.openWriter();
generateSomeOtherClass(writer, myTypeElement);
writer.close();

Upvotes: 0

Views: 338

Answers (1)

pendor
pendor

Reputation: 1790

I wonder if this is related to this bug in javac that's supposed to be fixed in Java 7? The compiler spews its errors early before it runs the annotation processors which ultimately make the errors not-really-errors and everything comes out in the end.

We've actually written a custom Ant task that extends the normal Ant javac task, overrides the various log() methods and attempts to silence errors that are likely to be spurious once all the annotation processing is complete. I'd post the code, but frankly it's very ugly, and I'd rather not unleash it on the world... Lots of big gnarly regexp's, and it's horribly brittle...

Upvotes: 2

Related Questions