Mercurial > hg > graal-jvmci-8
comparison jvmci/jdk.vm.ci.service.processor/src/jdk/vm/ci/service/processor/ServiceProviderProcessor.java @ 22743:f23c3e2022d9
workaround for Eclipse bug 367599
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Fri, 04 Dec 2015 13:47:46 +0100 |
parents | 1bbd4a7c274b |
children |
comparison
equal
deleted
inserted
replaced
22742:8a91781d5afc | 22743:f23c3e2022d9 |
---|---|
27 import java.io.PrintWriter; | 27 import java.io.PrintWriter; |
28 import java.util.HashSet; | 28 import java.util.HashSet; |
29 import java.util.Set; | 29 import java.util.Set; |
30 | 30 |
31 import javax.annotation.processing.AbstractProcessor; | 31 import javax.annotation.processing.AbstractProcessor; |
32 import javax.annotation.processing.FilerException; | |
32 import javax.annotation.processing.RoundEnvironment; | 33 import javax.annotation.processing.RoundEnvironment; |
33 import javax.annotation.processing.SupportedAnnotationTypes; | 34 import javax.annotation.processing.SupportedAnnotationTypes; |
34 import javax.lang.model.SourceVersion; | 35 import javax.lang.model.SourceVersion; |
35 import javax.lang.model.element.Element; | 36 import javax.lang.model.element.Element; |
36 import javax.lang.model.element.TypeElement; | 37 import javax.lang.model.element.TypeElement; |
97 FileObject file = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", filename, serviceProvider); | 98 FileObject file = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", filename, serviceProvider); |
98 PrintWriter writer = new PrintWriter(new OutputStreamWriter(file.openOutputStream(), "UTF-8")); | 99 PrintWriter writer = new PrintWriter(new OutputStreamWriter(file.openOutputStream(), "UTF-8")); |
99 writer.println(interfaceName); | 100 writer.println(interfaceName); |
100 writer.close(); | 101 writer.close(); |
101 } catch (IOException e) { | 102 } catch (IOException e) { |
102 processingEnv.getMessager().printMessage(Kind.ERROR, e.getMessage(), serviceProvider); | 103 processingEnv.getMessager().printMessage(isBug367599(e) ? Kind.NOTE : Kind.ERROR, e.getMessage(), serviceProvider); |
103 } | 104 } |
105 } | |
106 | |
107 /** | |
108 * Determines if a given exception is (most likely) caused by <a | |
109 * href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=367599">Bug 367599</a>. | |
110 */ | |
111 public static boolean isBug367599(Throwable t) { | |
112 if (t instanceof FilerException) { | |
113 for (StackTraceElement ste : t.getStackTrace()) { | |
114 if (ste.toString().contains("org.eclipse.jdt.internal.apt.pluggable.core.filer.IdeFilerImpl.create")) { | |
115 // See: https://bugs.eclipse.org/bugs/show_bug.cgi?id=367599 | |
116 return true; | |
117 } | |
118 } | |
119 } | |
120 if (t.getCause() != null) { | |
121 return isBug367599(t.getCause()); | |
122 } | |
123 return false; | |
104 } | 124 } |
105 | 125 |
106 @Override | 126 @Override |
107 public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { | 127 public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { |
108 if (roundEnv.processingOver()) { | 128 if (roundEnv.processingOver()) { |