JDK-6558580 : Annotation processing leads to types being incompatible with it self
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 6
  • Priority: P5
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2007-05-17
  • Updated: 2010-04-02
  • Resolved: 2010-03-10
Related Reports
Duplicate :  
Description
==> A.java <==
package test;

/**
 * @author brandon-enochs
 */
public class A {

        @X
        public void foo() {
        }

}

==> XAnnotationProcessor.java <==
import java.util.Set;

import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.RoundEnvironment;
import javax.annotation.processing.SupportedAnnotationTypes;
import javax.annotation.processing.SupportedOptions;
import javax.annotation.processing.SupportedSourceVersion;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.TypeElement;

/**
 * @author brandon-enochs
 */
@SupportedAnnotationTypes("*")
@SupportedOptions({})
@SupportedSourceVersion(SourceVersion.RELEASE_6)
public class XAnnotationProcessor extends AbstractProcessor {

// ------------------------ INTERFACE METHODS ------------------------

// --------------------- Interface Processor ---------------------

        public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
                return false;
        }



}

==> X.java <==
package test;

/**
 * @author brandon-enochs
 */
public @interface X {

        Y y() default Y.A;

        String a() default Z.BAR;

}

==> Y.java <==
package test;

/**
 * @author brandon-enochs
 */
public enum Y {

        A,
        B,
        C

}

==> Z.java <==
package test;

/**
 * @author brandon-enochs
 */
public class Z {

        public static final String BAR = "Bar";

}
$ javac XAnnotationProcessor.java
$ javac -processor XAnnotationProcessor A.java X.java Y.java Z.java
X.java:8: incompatible types
found   : test.Y
required: test.Y
        Y y() default Y.A;
                       ^
X.java:10: incompatible types
found   : java.lang.String
required: java.lang.String
        String a() default Z.BAR;
                            ^
2 errors
$ javac A.java X.java Y.java Z.java
$

Comments
EVALUATION Not reproducible on JDK 7; seems to be a duplicate of fixed bug 6512707.
10-03-2010