comparison graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/verify/VerifyTruffleProcessor.java @ 21420:fb17e716b03c

The annotation processor should verify proper use of @Child annotation during compilation time and prevent usage of final.
author Jaroslav Tulach <jaroslav.tulach@oracle.com>
date Tue, 19 May 2015 12:30:51 +0200
parents 8fd7354353b7
children c2b006c5e15f
comparison
equal deleted inserted replaced
21419:c1bb8028ff63 21420:fb17e716b03c
32 import javax.lang.model.*; 32 import javax.lang.model.*;
33 import javax.lang.model.element.*; 33 import javax.lang.model.element.*;
34 import javax.tools.Diagnostic.Kind; 34 import javax.tools.Diagnostic.Kind;
35 35
36 import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; 36 import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
37 import com.oracle.truffle.api.nodes.Node.Child;
37 38
38 @SupportedSourceVersion(SourceVersion.RELEASE_7) 39 @SupportedAnnotationTypes({"com.oracle.truffle.api.CompilerDirectives.TruffleBoundary", "com.oracle.truffle.api.nodes.Node.Child"})
39 @SupportedAnnotationTypes({"com.oracle.truffle.api.CompilerDirectives.TruffleBoundary"})
40 public class VerifyTruffleProcessor extends AbstractProcessor { 40 public class VerifyTruffleProcessor extends AbstractProcessor {
41 @Override 41 @Override
42 public SourceVersion getSupportedSourceVersion() { 42 public SourceVersion getSupportedSourceVersion() {
43 return SourceVersion.latest(); 43 return SourceVersion.latest();
44 } 44 }
111 reportException(isBug367599(t) ? Kind.NOTE : Kind.ERROR, element, t); 111 reportException(isBug367599(t) ? Kind.NOTE : Kind.ERROR, element, t);
112 } finally { 112 } finally {
113 scope = null; 113 scope = null;
114 } 114 }
115 } 115 }
116
117 for (Element e : roundEnv.getElementsAnnotatedWith(Child.class)) {
118 if (e.getModifiers().contains(Modifier.FINAL)) {
119 errorMessage(e, "@Child field cannot be final");
120 }
121 }
116 return false; 122 return false;
117 } 123 }
118 124
119 /** 125 /**
120 * Determines if a given exception is (most likely) caused by <a 126 * Determines if a given exception is (most likely) caused by <a