Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTill Brychcy2018-10-13 09:45:26 +0000
committerTill Brychcy2018-10-13 13:53:27 +0000
commitd33fe2c4fa66e382227d407614e9d343a136e103 (patch)
tree2876b8797692ba0dedb412730fcf47360dddc032 /org.eclipse.jdt.compiler.apt.tests
parentf6a107d3bbee6b3bf3da01547bbaf1ab5e41734d (diff)
downloadeclipse.jdt.core-d33fe2c4fa66e382227d407614e9d343a136e103.tar.gz
eclipse.jdt.core-d33fe2c4fa66e382227d407614e9d343a136e103.tar.xz
eclipse.jdt.core-d33fe2c4fa66e382227d407614e9d343a136e103.zip
Bug 540090 - Unjustified FilerException "Source file already exists" inI20181013-1800
Diffstat (limited to 'org.eclipse.jdt.compiler.apt.tests')
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/lib/apttestprocessors.jarbin210026 -> 212601 bytes
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/lib/apttestprocessors8.jarbin246788 -> 246790 bytes
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/AnnotationProcessorTests/Bug540090Proc.java53
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/resources/targets/AnnotationProcessorTests/bug540090/B.java21
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/resources/targets/AnnotationProcessorTests/bug540090/Bug540090.java16
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/AllTests.java3
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/AnnotationProcessorTests.java16
7 files changed, 107 insertions, 2 deletions
diff --git a/org.eclipse.jdt.compiler.apt.tests/lib/apttestprocessors.jar b/org.eclipse.jdt.compiler.apt.tests/lib/apttestprocessors.jar
index 00ae9b850d..8dee696aba 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/lib/apttestprocessors8.jar b/org.eclipse.jdt.compiler.apt.tests/lib/apttestprocessors8.jar
index 06baf9adef..1865ddef1a 100644
--- a/org.eclipse.jdt.compiler.apt.tests/lib/apttestprocessors8.jar
+++ b/org.eclipse.jdt.compiler.apt.tests/lib/apttestprocessors8.jar
Binary files differ
diff --git a/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/AnnotationProcessorTests/Bug540090Proc.java b/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/AnnotationProcessorTests/Bug540090Proc.java
new file mode 100644
index 0000000000..b63abf0372
--- /dev/null
+++ b/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/AnnotationProcessorTests/Bug540090Proc.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Till Brychcy and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Till Brychcy - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.compiler.apt.tests.processors.AnnotationProcessorTests;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.Set;
+
+import javax.annotation.processing.AbstractProcessor;
+import javax.annotation.processing.Filer;
+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 javax.tools.JavaFileObject;
+
+@SupportedAnnotationTypes("targets.AnnotationProcessorTests.Bug540090.Bug540090")
+@SupportedSourceVersion(SourceVersion.RELEASE_6)
+public class Bug540090Proc extends AbstractProcessor
+{
+ @Override
+ public boolean process(Set<? extends TypeElement> annotations,
+ RoundEnvironment roundEnv) {
+ Filer filer = processingEnv.getFiler();
+ if (!annotations.isEmpty()) {
+ try {
+ JavaFileObject jfo = filer.createSourceFile("gen.GenClass");
+ Writer writer = jfo.openWriter();
+ writer.write("package gen;\n");
+ writer.write("public class GenClass {\n");
+ writer.write(" int x;");
+ writer.write("}\n");
+ writer.close();
+ return true;
+ } catch (IOException e) {
+ return false;
+ }
+ }
+ return true;
+ }
+}
diff --git a/org.eclipse.jdt.compiler.apt.tests/resources/targets/AnnotationProcessorTests/bug540090/B.java b/org.eclipse.jdt.compiler.apt.tests/resources/targets/AnnotationProcessorTests/bug540090/B.java
new file mode 100644
index 0000000000..44cbc35b01
--- /dev/null
+++ b/org.eclipse.jdt.compiler.apt.tests/resources/targets/AnnotationProcessorTests/bug540090/B.java
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Till Brychcy and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Till Brychcy - initial API and implementation
+ *******************************************************************************/
+package targets.AnnotationProcessorTests.Bug540090;
+
+@Bug540090
+public class B {
+ public void foo(gen.GenClass x) {
+ return;
+ }
+}
diff --git a/org.eclipse.jdt.compiler.apt.tests/resources/targets/AnnotationProcessorTests/bug540090/Bug540090.java b/org.eclipse.jdt.compiler.apt.tests/resources/targets/AnnotationProcessorTests/bug540090/Bug540090.java
new file mode 100644
index 0000000000..14804d2464
--- /dev/null
+++ b/org.eclipse.jdt.compiler.apt.tests/resources/targets/AnnotationProcessorTests/bug540090/Bug540090.java
@@ -0,0 +1,16 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Till Brychcy and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Till Brychcy - initial API and implementation
+ *******************************************************************************/
+package targets.AnnotationProcessorTests.Bug540090;
+
+public @interface Bug540090 {} \ No newline at end of file
diff --git a/org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/AllTests.java b/org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/AllTests.java
index 0e034c33d6..9491959c63 100644
--- a/org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/AllTests.java
+++ b/org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/AllTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2017 IBM, BEA Systems, Inc. and others
+ * Copyright (c) 2006, 2018 IBM, BEA Systems, Inc. and others
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -35,6 +35,7 @@ public class AllTests extends TestCase {
suite.addTestSuite(NegativeTests.class);
suite.addTestSuite(Java8ElementsTests.class);
suite.addTestSuite(Java9ElementsTests.class);
+ suite.addTestSuite(Java11ElementsTests.class);
suite.addTestSuite(AnnotationProcessorTests.class);
return suite;
}
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 e70d5a788b..358d6fff93 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2014, 2015 IBM Corporation and others.
+ * Copyright (c) 2014, 2018 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -97,6 +97,20 @@ public class AnnotationProcessorTests extends TestCase {
assertEquals(true, success);
}
+ public void testBug540090() throws IOException {
+ JavaCompiler compiler = BatchTestUtils.getEclipseCompiler();
+ File targetFolder = TestUtils.concatPath(BatchTestUtils.getSrcFolderName(), "targets", "AnnotationProcessorTests", "bug540090");
+ BatchTestUtils.copyResources("targets/AnnotationProcessorTests/bug540090", targetFolder);
+ List<String> options = new ArrayList<String>();
+ final String PROC = "org.eclipse.jdt.compiler.apt.tests.processors.AnnotationProcessorTests.Bug540090Proc";
+ options.add("-processorpath");
+ options.add(" ");
+ options.add("-processor");
+ options.add(PROC);
+ boolean success = BatchTestUtils.compileTreeWithErrors(compiler, options, targetFolder, null);
+ assertEquals(true, success);
+ }
+
public void testBug415274() throws IOException {
JavaCompiler compiler = BatchTestUtils.getEclipseCompiler();
File targetFolder = TestUtils.concatPath(BatchTestUtils.getSrcFolderName(), "targets", "AnnotationProcessorTests", "bug415274");

Back to the top