Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Arthanareeswaran2018-05-17 11:18:31 -0400
committerJay Arthanareeswaran2018-05-23 00:18:05 -0400
commit7a7103893293ccaa08503110334998347e22f2e4 (patch)
treed3f6dd98cdb273282e72d90e5e114e54d9b48f90 /org.eclipse.jdt.compiler.apt.tests
parent95dc2d8aefb5a76afa0aa18c2377113a9ae06fd5 (diff)
downloadeclipse.jdt.core-7a7103893293ccaa08503110334998347e22f2e4.tar.gz
eclipse.jdt.core-7a7103893293ccaa08503110334998347e22f2e4.tar.xz
eclipse.jdt.core-7a7103893293ccaa08503110334998347e22f2e4.zip
spring-boot-configuration-processor compatibility Change-Id: I8eb3026d6fe97f7cc0a1e2b2cf46e287f08d1c8e Signed-off-by: Jay Arthanareeswaran <jarthana@in.ibm.com>
Diffstat (limited to 'org.eclipse.jdt.compiler.apt.tests')
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/lib/apttestprocessors.jarbin207081 -> 210026 bytes
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/AnnotationProcessorTests/Bug530665Proc.java87
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/resources/targets/AnnotationProcessorTests/bug530665/A.java3
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/AnnotationProcessorTests.java25
4 files changed, 115 insertions, 0 deletions
diff --git a/org.eclipse.jdt.compiler.apt.tests/lib/apttestprocessors.jar b/org.eclipse.jdt.compiler.apt.tests/lib/apttestprocessors.jar
index 69a7439122..00ae9b850d 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/Bug530665Proc.java b/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/AnnotationProcessorTests/Bug530665Proc.java
new file mode 100644
index 0000000000..01c79e22a3
--- /dev/null
+++ b/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/AnnotationProcessorTests/Bug530665Proc.java
@@ -0,0 +1,87 @@
+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.Filer;
+import javax.annotation.processing.ProcessingEnvironment;
+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.FileObject;
+import javax.tools.StandardLocation;
+
+import org.eclipse.jdt.compiler.apt.tests.processors.base.BaseProcessor;
+
+@SupportedAnnotationTypes("*")
+@SupportedSourceVersion(SourceVersion.RELEASE_6)
+public class Bug530665Proc extends BaseProcessor {
+
+ private Filer filer;
+
+ @Override
+ public synchronized void init(ProcessingEnvironment processingEnv) {
+ super.init(processingEnv);
+ filer = processingEnv.getFiler();
+ }
+
+ @Override
+ public void reportError(String value) {
+ super.reportError(value);
+ throw new RuntimeException(value);
+ }
+
+ @Override
+ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+ if (roundEnv.errorRaised()) {
+ return false;
+ }
+
+ try {
+ filer.getResource(StandardLocation.CLASS_OUTPUT, "targets/AnnotationProcessorTests/bug530665", "nonexists.txt");
+ reportError("Filer.getResource(nonexists.txt) did NOT throw!");
+ } catch (IOException e) {
+ // ignored
+ }
+ try {
+ // can be done multiple times...
+ filer.getResource(StandardLocation.CLASS_OUTPUT, "targets/AnnotationProcessorTests/bug530665", "preexists.txt");
+ filer.getResource(StandardLocation.CLASS_OUTPUT, "targets/AnnotationProcessorTests/bug530665", "preexists.txt");
+ } catch (IOException e) {
+ reportError("Filer.getResource(preexists.txt) threw: " + e);
+ }
+
+ if (roundEnv.processingOver()) {
+ try {
+ FileObject fo = filer.createResource(StandardLocation.CLASS_OUTPUT, "targets/AnnotationProcessorTests/bug530665", "nonexists.txt");
+ try(Writer writer = fo.openWriter()) {
+ writer.append("Test");
+ }
+ } catch(IOException e) {
+ reportError("Filer.createResource(nonexists.txt) threw: " + e);
+ }
+ try {
+ filer.createResource(StandardLocation.CLASS_OUTPUT, "targets/AnnotationProcessorTests/bug530665", "nonexists.txt");
+ reportError("Filer.createResource(nonexists.txt) second attempt did NOT throw!");
+ } catch(IOException e) {
+ // ignored
+ }
+
+ try {
+ FileObject fo = filer.createResource(StandardLocation.CLASS_OUTPUT, "targets/AnnotationProcessorTests/bug530665", "preexists.txt");
+ if (!fo.delete()) {
+ reportError("FileObject.delete() failed!");
+ }
+ } catch(IOException e) {
+ reportError("Filer.createResource(preexists.txt) threw: " + e);
+ }
+
+ reportSuccess();
+ }
+ return false;
+ }
+
+}
diff --git a/org.eclipse.jdt.compiler.apt.tests/resources/targets/AnnotationProcessorTests/bug530665/A.java b/org.eclipse.jdt.compiler.apt.tests/resources/targets/AnnotationProcessorTests/bug530665/A.java
new file mode 100644
index 0000000000..132e1e2eb0
--- /dev/null
+++ b/org.eclipse.jdt.compiler.apt.tests/resources/targets/AnnotationProcessorTests/bug530665/A.java
@@ -0,0 +1,3 @@
+package targets.AnnotationProcessorTests.bug530665;
+
+public class A {}
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 ae091acea5..7be23b6eba 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
@@ -175,4 +175,29 @@ public class AnnotationProcessorTests extends TestCase {
assertEquals("incorrect number of messages", 0, diagnosticListener.count);
assertNull(System.getProperty(PROC));
}
+
+ public void testBug530665() throws IOException {
+ JavaCompiler compiler = BatchTestUtils.getEclipseCompiler();
+ File srcFolder = TestUtils.concatPath(BatchTestUtils.getSrcFolderName(), "targets", "AnnotationProcessorTests", "bug317216");
+ BatchTestUtils.copyResources("targets/AnnotationProcessorTests/bug530665", srcFolder);
+ File binFolder = TestUtils.concatPath(BatchTestUtils.getBinFolderName(), "targets", "AnnotationProcessorTests", "bug530665");
+ binFolder.mkdirs();
+ File preexistsFile = new File(binFolder, "preexists.txt");
+ assertTrue(preexistsFile.createNewFile());
+ File nonexistsFile = new File(binFolder, "nonexists.txt");
+ assertTrue(!nonexistsFile.exists());
+
+ List<String> options = new ArrayList<String>();
+ final String PROC = "org.eclipse.jdt.compiler.apt.tests.processors.AnnotationProcessorTests.Bug530665Proc";
+ options.add("-processorpath");
+ options.add(" ");
+ options.add("-processor");
+ options.add(PROC);
+ DiagnosticReport<JavaFileObject> diagnosticListener = new DiagnosticReport<JavaFileObject>();
+ BatchTestUtils.compileTree(compiler, options, srcFolder, false, diagnosticListener);
+ assertEquals("succeeded", System.getProperty(PROC));
+
+ assertTrue(!preexistsFile.exists()); // deleted
+ assertTrue(nonexistsFile.exists()); // rewritten
+ }
}

Back to the top