Community
Participate
Working Groups
- I have a class "ClassWithParamAnnotations" with methods with parameters with annotations. - This class is not related to any generated class and it also does not trigger code generation. - In my annotation processor, I lookup this class by Elements.getTypeElement. - In first round of processing, that type element correctly contains the parameter annotations on its methods. - In subsequent rounds of processing, those annotations are missing. (Other annotations like method and class level annotations ares still there). - This happens only, if I have some other class that refers to a type to be generated by the annotation processor. I did some debugging and found the following: - In first round, the parameter annotations are resolved correctly by AnnotationDiscoveryVisitor. - As I understand, this visitor is only called for root elements of the round. - After first round, all types are re-compiled, including the "ClassWithParamAnnotations". This is done, since Eclipse discovered that there has been a reference to a missing type that now has been generated (see Compiler.compile() amd there: catch (SourceTypeCollisionException e)) - Due to re-compilation, a new SourceTypeBinding is created for "ClassWithParamAnnotations". However, the AnnotationDiscoveryVisitor is not applied here, since it is not a root element for second round. - There seems to be no other place, where the parameter anntoations get resolved: Debbuging into LocalVariableBinding.getAnnotations() for this case shows, that Binding.NO_ANNOTATIONS is returned, since DeclaringScope is null for the LocalVariableBinding. - Thus, the parameter annotations never get resolved.
Created attachment 239767 [details] Processor and example project to reproduce the bug Steps to reproduce: 1.) unzip attachement 2.) for project eclipse-bug-processor, call "mvn install" to create the processor 3.) import project "eclipse-bug-test" as maven project into eclipse 4.) Either install the m2e-apt connector as suggested. (if not done before) Make sure, the m2e-option "Automatically configure JDT APT is selected" 5.) Open the Error Log. You should see messages for 3 rounds of annotation processing there. In first round, you see: aMethod [@test.SomeAnnotation], Parameters: aParam [@test.SomeAnnotation], In 2nd and 3rd round, you see the bug: aMethod [@test.SomeAnnotation], Parameters: aParam [],
Jay, please triage. TIA.
At the moment we are overloaded with Java 8 work and unlikely to be able to look at this during Luna timeframe. However, if someone can come up with a patch, I can review and release.
Hello, any news here? If I could, I would help more, but this is just "to deep" in apt for me... Best Regards, Stefan.
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie.
Dear Eclipse Genie, this bug is still relevant.