| Summary: | Not able to use Java 6 APT | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | [Tools] AJDT | Reporter: | Andrew Eisenberg <andrew.eisenberg> | ||||||
| Component: | Core | Assignee: | AJDT-inbox <AJDT-inbox> | ||||||
| Status: | RESOLVED FIXED | QA Contact: | |||||||
| Severity: | normal | ||||||||
| Priority: | P3 | CC: | aclement, donmayr, eggyal, guoliangqian, iloncar.ml+eclipse, mfj, stupin.sergey, zregvart+eclipse | ||||||
| Version: | 2.1.2 | ||||||||
| Target Milestone: | 2.2.4 | ||||||||
| Hardware: | Macintosh | ||||||||
| OS: | Mac OS X | ||||||||
| Whiteboard: | |||||||||
| Attachments: |
|
||||||||
|
Description
Andrew Eisenberg
Created attachment 194279 [details]
A sample project with an annotation processor
These two projects were sent to me by email and show a simple example of where AJDT does not run APT.
Created attachment 194281 [details]
An ant build script generated by eclipse and edited to use AJC instead of Javac
This ant script will compile the test project using ajc in batch mode. You can see in the results that APT is called correctly. To run this script, place this script in the root of the HelloWorld-Test project. You must also edit the hard coded paths to match your filesystem.
It seems that currently, AJDT is not set up to work with the Java6 APT, but AJC is. There might be a way that AJDT can initialize AJC's version of APT before a build starts. Consider for the 2.2.0 release. I think this issue may be the root of that described at http://code.google.com/p/google-web-toolkit/issues/detail?id=7083 - pretty catastrophic for Spring Roo + GWT 2.4 ! I don't suppose there is a workaround at present? Consider for the 2.2.1 release. Consider for 2.2.2. For roo+gwt there might be a 'workaround': - Ensure the eclipse project config matches description of http://code.google.com/p/google-web-toolkit/wiki/RequestFactoryInterfaceValidation - Remove any '.apt_generated' directory from the project. - On the command-line run 'mvn gwt:run' - this should generate anew the '.apt_generated' directory - Now run the application from eclipse. This should make it possible to run roo+gwt generated projects from eclipse, but it's still cumbersome. (In reply to Andrew Eisenberg from comment #7) > Consider for 2.2.2. Has this been fixed? How do I tell from the bugzilla? I asked for an update on this bug 12 days ago. Is there no one looking at this bug? This bug is not on our plan for the next release. This bug is catastrophic for Spring Roo+GWT. Is there some plan to resolve this. AJDT and AJC should not work differently. Even if it were not for Spring Roo+GWT having a catastrophic effect, this AJDT should support Java6 annotations. When is this going to be fixed in AJDT? I'm afraid supporting this has still not bubbled up to the top of the priority list. When will it? I'm honestly not sure. We are now at java 8 and AJDT still does not support java 6 annotation. Any chances this can be fixed soon? If anyone who is watching this bug is interested in getting it fix can you please: 1. Vote for the bug 2. Get anyone in your organization interested to vote for it. Currently there are only 5 votes. Some annotation processing work is currently being done for bug 252199 - I am processing a couple of pull requests in relation to that issue. I don't understand because bug 252199 is in AspectJ. The comments indicate that the batch AJC works but when run in the IDE it does not. This seems to imply that the support is already in AspectJ and I do not understand how fixing bug 252199 will help this bug. Could you also elaborate on what your last comment means in term of fixing this bug. Thanks. Ok, this is indeed strange bug so let me clarify some things. I don't know how ajc could handle APT properly to the moment when this bug was created (who knows, it was 3 years ago) but I can assure you that in last release version 1.8.1 ajc definitely skips annotation processing in whatever mode: batch or incremental. So I will try to explain why: 1. ajc uses patched version of jdt compiler. Here is a repo: https://github.com/eclipse/org.aspectj.shadows 2. If you look at line https://github.com/eclipse/org.aspectj.shadows/blob/aj_BETA_JAVA8_LUNA_c0f9341/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/Compiler.java#L431 you see, that ATP is running only if annotationProcessingManager was initialized. 3. annotationProcessingManager could be initialized in ajc project inside method org.aspectj.org.eclipse.jdt.internal.compiler.batch.Main#initializeAnnotationProcessorManager 4. At the beginning this method tries to load class org.eclipse.jdt.internal.compiler.apt.dispatch.BatchAnnotationProcessorManager 5. That class BatchAnnotationProcessorManager was added to that patched version of jdt compiler by me 1 month ago. So if anybody could create a small project with working annotation processing which could be compiled only by ajc 1.8.1 (without any precompilation javac steps which could potentially process APT) I will really appreciate that. BTW, APT should work in ajc 1.8.2 but not in ide yet. Let me write up my findings. Mostly it is behaving as Andrew originally wrote. The Java5 annotation processing uses a compilation participant to do the annotation processing ahead of the compiler doing its work (compiling the original sources plus any generated sources). The Java6 annotation processing is done as part of the real compiler, and really the difference between running it command line vs running it in AJDT is being able to get that processorpath supplied to the compiler. Outside of the workbench it is a simple -processorpath XXX but inside AJDT we need some machinery to pass across the factory path (as defined in the project properties annotation processing section). So I have implemented that (effectively what Andrew describes in comment 3) and it does work. Generating aspects is a little more hairy than generating regular java source code but they do seem to behave. The only failure I've seen so far is that the gutter markers that show where advice in effect will break if you try to use them for navigation and the code they point to was actually generated. I will tidy this up and commit it very soon, then it would be great to get some of you to kick the tyres on it. The markers thing can be fixed up later. Dev builds are through. I'm closing this as fixed ! I've written up how to use it: http://andrewclement.blogspot.ca/2014/08/annotation-processing-in-ajdt.html The update site is here (for Eclipse 4.4): http://download.eclipse.org/tools/ajdt/44/dev/update I don't plan on back porting this to Eclipse 4.3 unless there is enough feedback that justifies it. |