< prev index next >

test/langtools/tools/javac/lib/JavacTestingAbstractProcessor.java

Print this page

 81         if (sat != null)
 82             return super.getSupportedAnnotationTypes();
 83         else
 84             return allAnnotations;
 85     }
 86 
 87     @Override
 88     public void init(ProcessingEnvironment processingEnv) {
 89         super.init(processingEnv);
 90         elements = eltUtils  = processingEnv.getElementUtils();
 91         types = typeUtils = processingEnv.getTypeUtils();
 92         filer     = processingEnv.getFiler();
 93         messager  = processingEnv.getMessager();
 94         options   = processingEnv.getOptions();
 95     }
 96 
 97     protected void addExports(String moduleName, String... packageNames) {
 98         for (String packageName : packageNames) {
 99             try {
100                 ModuleLayer layer = ModuleLayer.boot();
101                 Optional<Module> m = layer.findModule(moduleName);
102                 if (!m.isPresent())

103                     throw new Error("module not found: " + moduleName);
104                 m.get().addExports(packageName, getClass().getModule());
105             } catch (Exception e) {
106                 throw new Error("failed to add exports for " + moduleName + "/" + packageName);
107             }
108         }
109     }
110 
111     /*
112      * The set of visitors below will directly extend the most recent
113      * corresponding platform visitor type.
114      */
115 
116     @SupportedSourceVersion(RELEASE_24)
117     @SuppressWarnings("preview")
118     public static abstract class AbstractAnnotationValueVisitor<R, P> extends AbstractAnnotationValueVisitorPreview<R, P> {
119 
120         /**
121          * Constructor for concrete subclasses to call.
122          */
123         protected AbstractAnnotationValueVisitor() {
124             super();

 81         if (sat != null)
 82             return super.getSupportedAnnotationTypes();
 83         else
 84             return allAnnotations;
 85     }
 86 
 87     @Override
 88     public void init(ProcessingEnvironment processingEnv) {
 89         super.init(processingEnv);
 90         elements = eltUtils  = processingEnv.getElementUtils();
 91         types = typeUtils = processingEnv.getTypeUtils();
 92         filer     = processingEnv.getFiler();
 93         messager  = processingEnv.getMessager();
 94         options   = processingEnv.getOptions();
 95     }
 96 
 97     protected void addExports(String moduleName, String... packageNames) {
 98         for (String packageName : packageNames) {
 99             try {
100                 ModuleLayer layer = ModuleLayer.boot();
101                 // removing dependency on java.util.Optional, valhalla only, to avoid VM warnings
102                 Module m = layer.findModule(moduleName).get();
103                 if (m == null)
104                     throw new Error("module not found: " + moduleName);
105                 m.addExports(packageName, getClass().getModule());
106             } catch (Exception e) {
107                 throw new Error("failed to add exports for " + moduleName + "/" + packageName);
108             }
109         }
110     }
111 
112     /*
113      * The set of visitors below will directly extend the most recent
114      * corresponding platform visitor type.
115      */
116 
117     @SupportedSourceVersion(RELEASE_24)
118     @SuppressWarnings("preview")
119     public static abstract class AbstractAnnotationValueVisitor<R, P> extends AbstractAnnotationValueVisitorPreview<R, P> {
120 
121         /**
122          * Constructor for concrete subclasses to call.
123          */
124         protected AbstractAnnotationValueVisitor() {
125             super();
< prev index next >