Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJayaprakash Arthanareeswaran2015-03-27 09:25:41 +0000
committerJayaprakash Arthanareeswaran2015-03-27 13:33:34 +0000
commitefcbc8246985c2d4ce62d9f4d57040e9d6aab069 (patch)
tree44ecae8d39a2fe63f513f43b87e2ac5fe5e4c431 /org.eclipse.jdt.compiler.apt.tests
parent7163191ad837ee4dbd99301bb257966d1ab9ea7a (diff)
downloadeclipse.jdt.core-efcbc8246985c2d4ce62d9f4d57040e9d6aab069.tar.gz
eclipse.jdt.core-efcbc8246985c2d4ce62d9f4d57040e9d6aab069.tar.xz
eclipse.jdt.core-efcbc8246985c2d4ce62d9f4d57040e9d6aab069.zip
Bug 463062 - Annotation processing runs when annotation is on an
incompatible target element Change-Id: I1db2a2016c0051b6eabbbb1b0105563142eec8b1
Diffstat (limited to 'org.eclipse.jdt.compiler.apt.tests')
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/lib/apttestprocessors.jarbin187716 -> 189469 bytes
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/AnnotationProcessorTests/Bug463062Proc.java34
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/base/BaseProcessor.java6
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/resources/targets/AnnotationProcessorTests/bug463062/EBean.java11
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/resources/targets/AnnotationProcessorTests/bug463062/MyClass.java4
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/AnnotationProcessorTests.java14
6 files changed, 68 insertions, 1 deletions
diff --git a/org.eclipse.jdt.compiler.apt.tests/lib/apttestprocessors.jar b/org.eclipse.jdt.compiler.apt.tests/lib/apttestprocessors.jar
index 3c91d90f09..1b5f5ed691 100644
--- a/org.eclipse.jdt.compiler.apt.tests/lib/apttestprocessors.jar
+++ b/org.eclipse.jdt.compiler.apt.tests/lib/apttestprocessors.jar
Binary files differ
diff --git a/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/AnnotationProcessorTests/Bug463062Proc.java b/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/AnnotationProcessorTests/Bug463062Proc.java
new file mode 100644
index 0000000000..bd8ebcfbed
--- /dev/null
+++ b/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/AnnotationProcessorTests/Bug463062Proc.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2015 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ *******************************************************************************/
+
+package org.eclipse.jdt.compiler.apt.tests.processors.AnnotationProcessorTests;
+
+import java.util.Set;
+
+import javax.annotation.processing.RoundEnvironment;
+import javax.annotation.processing.SupportedAnnotationTypes;
+import javax.annotation.processing.SupportedSourceVersion;
+import javax.lang.model.SourceVersion;
+import javax.lang.model.element.TypeElement;
+
+import org.eclipse.jdt.compiler.apt.tests.processors.base.BaseProcessor;
+
+/**
+ * A processor that should not be invoked. Reports an error if invoked.
+ */
+@SupportedAnnotationTypes({"targets.AnnotationProcessorTests.bug463062.EBean"})
+@SupportedSourceVersion(SourceVersion.RELEASE_6)
+public class Bug463062Proc extends BaseProcessor {
+ @Override
+ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+ reportFailure(); // The annotation processor should never be invoked (https://bugs.eclipse.org/bugs/show_bug.cgi?id=463062)
+ return false;
+ }
+
+}
diff --git a/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/base/BaseProcessor.java b/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/base/BaseProcessor.java
index 092136212c..3d28b509d5 100644
--- a/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/base/BaseProcessor.java
+++ b/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/base/BaseProcessor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 BEA Systems, Inc.
+ * Copyright (c) 2007, 2015 BEA Systems, Inc and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -41,6 +41,10 @@ public abstract class BaseProcessor extends AbstractProcessor
System.setProperty(this.getClass().getName(), "succeeded");
}
+ public void reportFailure() {
+ System.setProperty(this.getClass().getName(), "failed");
+ }
+
@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
super.init(processingEnv);
diff --git a/org.eclipse.jdt.compiler.apt.tests/resources/targets/AnnotationProcessorTests/bug463062/EBean.java b/org.eclipse.jdt.compiler.apt.tests/resources/targets/AnnotationProcessorTests/bug463062/EBean.java
new file mode 100644
index 0000000000..b8c41fa683
--- /dev/null
+++ b/org.eclipse.jdt.compiler.apt.tests/resources/targets/AnnotationProcessorTests/bug463062/EBean.java
@@ -0,0 +1,11 @@
+package targets.AnnotationProcessorTests.bug463062;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention(RetentionPolicy.CLASS)
+@Target(ElementType.TYPE)
+public @interface EBean {
+} \ No newline at end of file
diff --git a/org.eclipse.jdt.compiler.apt.tests/resources/targets/AnnotationProcessorTests/bug463062/MyClass.java b/org.eclipse.jdt.compiler.apt.tests/resources/targets/AnnotationProcessorTests/bug463062/MyClass.java
new file mode 100644
index 0000000000..9c1d4bebb5
--- /dev/null
+++ b/org.eclipse.jdt.compiler.apt.tests/resources/targets/AnnotationProcessorTests/bug463062/MyClass.java
@@ -0,0 +1,4 @@
+package targets.AnnotationProcessorTests.bug463062;
+public class MyClass {
+ @EBean Object field;
+}
diff --git a/org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/AnnotationProcessorTests.java b/org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/AnnotationProcessorTests.java
index 89c0d3dc4c..74170ce3a0 100644
--- a/org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/AnnotationProcessorTests.java
+++ b/org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/AnnotationProcessorTests.java
@@ -69,4 +69,18 @@ public class AnnotationProcessorTests extends TestCase {
boolean success = BatchTestUtils.compileTreeWithErrors(compiler, options, targetFolder, null, false);
assertEquals(true, success);
}
+
+ public void testBug463062() throws IOException {
+ JavaCompiler compiler = BatchTestUtils.getEclipseCompiler();
+ File targetFolder = TestUtils.concatPath(BatchTestUtils.getSrcFolderName(), "targets", "AnnotationProcessorTests", "bug463062");
+ BatchTestUtils.copyResources("targets/AnnotationProcessorTests/bug463062", targetFolder);
+ List<String> options = new ArrayList<String>();
+ final String PROC = "org.eclipse.jdt.compiler.apt.tests.processors.AnnotationProcessorTests.Bug463062Proc";
+ options.add("-processorpath");
+ options.add(" ");
+ options.add("-processor");
+ options.add(PROC);
+ BatchTestUtils.compileTreeWithErrors(compiler, options, targetFolder, null, true);
+ assertNull(System.getProperty(PROC));
+ }
}

Back to the top