Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jdt-core-dev] Why was the Annotation processing in Eclipse made so different from javac?

Sorry I missed your forum post, I have not been following the forums lately.

I think you have a bit of confusion about the role the annotation processor plays.  An annotation processor is a compiler plug-in.  Loading an annotation processor from the project path would be like loading any other Eclipse plug-in from the project path.  How would you unload it when done so as to allow editing of the code?  You would need to exit and restart Eclipse.

The reason javac gets away with it is that you *do* exit and restart javac with every new compilation.  Even there, though, it's not conceptually a particularly clear-headed idea: it is mixing concerns.  The annotation processor is not part of the source code, it is part of the compiler.

Also, yes, it is quite expensive to check for processors in the classpath.  The classpath includes jar files that contain .class files.  You can't just look for source code; a processor is not required to be source code.

Remember that Eclipse is an incremental compiler, not a batch compiler like javac.  It tries to *not* load the entire world on every compile.

If you're using the Eclipse compiler (ecj) from the command line, it does use all the same command line options as javac, and you can plug it into Maven.

I can't speak for the Maven integration in Eclipse, because that happened a long time after the annotation processing code was written.

Thanks,
  -walter harley (one of the original Eclipse APT authors)


On Sat, Mar 15, 2014 at 4:57 AM, Ilya Basin <basinilya@xxxxxxxxx> wrote:
Hello. I already asked this in the forum, but got no reply. http://www.eclipse.org/forums/index.php/t/665448/

Why annotation processing is off by default? One could say the
opposite would slow down things, but isn't a better trigger to enable
the processing - the presence of unknown annotations in the source
code (not @Override, @Deprecated etc.)? Other annotations are rare and
for most projects the processing would be inactive.

Why the project classpath is not used to find the annotation processors?
Perfomance again? Is it really slow to check for the file
"javax.annotation.processing.Processor" in the whole classpath?
Well, at least, in normal eclipse project this can be solved by
adding .factorypath under source control.
More problematic are maven projects. If it's a popular annotation
processor (like JPA) then it even works out of the box, because the
plugin supports it. But no custom annotations for us!

Why java projects can't be added to Factory Path? Why only jars are allowed?
I even tried to add custom ant builder to make me a jar, but this
doesn't work, because the Factory Path of a project is loaded BEFORE
the dependencies are built and for the edits in the custom processors
to take effect I had to restart eclipse.

_______________________________________________
jdt-core-dev mailing list
jdt-core-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/jdt-core-dev



Back to the top