Skip to main content

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

Hello Csaba,

This doesn't appear to be a case of deliberate decision. But looks like it has always been like this. I will look into this.
Meanwhile, can you please raise a bug for this so we can discuss. I am not sure, but may be there are people who are interested in knowing regardless of the validity of incorrect target. May be they are already depending on incorrect behavior. We would like to hear from them as well on this.

Regards,
Jay



From:        Csaba Kozák <kozakcsabi@xxxxxxxxx>
To:        jdt-dev@xxxxxxxxxxx
Date:        03/24/2015 08:01 PM
Subject:        [jdt-dev] Annotation processing runs when annotation is on an incompatible target element
Sent by:        jdt-dev-bounces@xxxxxxxxxxx




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_______________________________________________
jdt-dev mailing list
jdt-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jdt-dev

Back to the top