Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jdt-dev] Annotation processing runs when annotation is on an incompatible target element

Hi!

I already sent this to jdt-apt-dev, but that list seems to be dead so i am resending here.

We encountered this with AndroidAnnotations. So basically the user added an annotation which has @Target(ElementType.TYPE)to a field. This is of course invalid and produces a compilation error. However in JDT APT, annotation processing still runs for the added annotation. I think this not makes sense, since the processor handling the annotation expects that it is put on a type element, and not on a field element. Also javac does not run annotation processing for this added annotation. I know JDT is an incremental compiler, but we at AndroidAnnotations still think the processing should not be called for this annotation.

Full example:

@Retention(RetentionPolicy.CLASS)
@Target(ElementType.TYPE)
public @interface EBean {

}

public class MyClass {

    @MyAnnotation // cannot be on a field
    Object field;
}



Is this behavior intended in JDT APT?

I used JDT version 3.10.1.v20150204-1700 to test this.

Regards,
Csaba

Back to the top