diff options
Diffstat (limited to 'org.eclipse.jdt.apt.pluggable.tests/resources/targets/bug387956')
4 files changed, 80 insertions, 0 deletions
diff --git a/org.eclipse.jdt.apt.pluggable.tests/resources/targets/bug387956/Entity.java b/org.eclipse.jdt.apt.pluggable.tests/resources/targets/bug387956/Entity.java new file mode 100644 index 0000000000..b9ee2a7669 --- /dev/null +++ b/org.eclipse.jdt.apt.pluggable.tests/resources/targets/bug387956/Entity.java @@ -0,0 +1,12 @@ +package targets.bug387956; + +import targets.bug387956.Generate; + +/** + * Using {@link Generate} on {@link Entity} will generate the empty + * {@link generated.GeneratedEntity} class. + */ +@Generate +public class Entity { + +}
\ No newline at end of file diff --git a/org.eclipse.jdt.apt.pluggable.tests/resources/targets/bug387956/Generate.java b/org.eclipse.jdt.apt.pluggable.tests/resources/targets/bug387956/Generate.java new file mode 100644 index 0000000000..1fae923cbb --- /dev/null +++ b/org.eclipse.jdt.apt.pluggable.tests/resources/targets/bug387956/Generate.java @@ -0,0 +1,15 @@ +package targets.bug387956; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Used on a type "SomeType", generates a new empty class named + * "generated.GeneratedSomeType" + */ +@Retention(RetentionPolicy.SOURCE) +@Target(ElementType.TYPE) +public @interface Generate { +} diff --git a/org.eclipse.jdt.apt.pluggable.tests/resources/targets/bug387956/SomeAnnotation.java b/org.eclipse.jdt.apt.pluggable.tests/resources/targets/bug387956/SomeAnnotation.java new file mode 100644 index 0000000000..95389607e0 --- /dev/null +++ b/org.eclipse.jdt.apt.pluggable.tests/resources/targets/bug387956/SomeAnnotation.java @@ -0,0 +1,18 @@ +package targets.bug387956; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * A useless annotation that is not processed by the annotation processor. Any + * annotation can be used instead of this one to reproduce the bug. + */ +@Retention(RetentionPolicy.CLASS) +@Target(ElementType.FIELD) +public @interface SomeAnnotation { + + int value(); + +} diff --git a/org.eclipse.jdt.apt.pluggable.tests/resources/targets/bug387956/SomeClass.java b/org.eclipse.jdt.apt.pluggable.tests/resources/targets/bug387956/SomeClass.java new file mode 100644 index 0000000000..ad4f78917e --- /dev/null +++ b/org.eclipse.jdt.apt.pluggable.tests/resources/targets/bug387956/SomeClass.java @@ -0,0 +1,35 @@ +package targets.bug387956; + +/* + * The import triggers a compilation error, if SomeAnnotation has a reference to + * Integer.MAX_VALUE: "The import generated.GeneratedEntity cannot be resolved" + */ +import generated.GeneratedEntity; + + +@SuppressWarnings("unused") +public class SomeClass { + + /** + * The problem only occurs when you do a Project > Clean. It doesn't occur + * when saving the file without cleaning (incremental compilation), because + * cleaning removes generated.GeneratedEntity, which is then generated + * again. + * + * If you comment "@SomeAnnotation(Integer.MAX_VALUE)", the error + * disappears. + * + * If you replace Integer.MAX_VALUE with its value, the error disappears. + * + * This seems to be because {@link SomeAnnotation} fires the Eclipse + * annotation processing, which sees a reference that needs to be resolved + * (Integer.MAX_VALUE), and therefore tries to resolve imports, where it + * finds import {@link generated.GeneratedEntity} and cannot resolve it. + * + * This can happen with any annotation java 6 processor that generates code. + * Also note that I couldn't reproduce this on the simple java 5 processor + * given here: http://www.eclipse.org/jdt/apt/introToAPT.html + */ + @SomeAnnotation(Integer.MAX_VALUE) + Object none; +}
\ No newline at end of file |