93 94 protected void addExports(String moduleName, String... packageNames) { 95 for (String packageName : packageNames) { 96 try { 97 ModuleLayer layer = ModuleLayer.boot(); 98 Optional<Module> m = layer.findModule(moduleName); 99 if (!m.isPresent()) 100 throw new Error("module not found: " + moduleName); 101 m.get().addExports(packageName, getClass().getModule()); 102 } catch (Exception e) { 103 throw new Error("failed to add exports for " + moduleName + "/" + packageName); 104 } 105 } 106 } 107 108 /* 109 * The set of visitors below will directly extend the most recent 110 * corresponding platform visitor type. 111 */ 112 113 @SupportedSourceVersion(RELEASE_10) 114 public static abstract class AbstractAnnotationValueVisitor<R, P> extends AbstractAnnotationValueVisitor9<R, P> { 115 116 /** 117 * Constructor for concrete subclasses to call. 118 */ 119 protected AbstractAnnotationValueVisitor() { 120 super(); 121 } 122 } 123 124 @SupportedSourceVersion(RELEASE_10) 125 public static abstract class AbstractElementVisitor<R, P> extends AbstractElementVisitor9<R, P> { 126 /** 127 * Constructor for concrete subclasses to call. 128 */ 129 protected AbstractElementVisitor(){ 130 super(); 131 } 132 } 133 134 @SupportedSourceVersion(RELEASE_10) 135 public static abstract class AbstractTypeVisitor<R, P> extends AbstractTypeVisitor9<R, P> { 136 /** 137 * Constructor for concrete subclasses to call. 138 */ 139 protected AbstractTypeVisitor() { 140 super(); 141 } 142 } 143 144 @SupportedSourceVersion(RELEASE_10) 145 public static class ElementKindVisitor<R, P> extends ElementKindVisitor9<R, P> { 146 /** 147 * Constructor for concrete subclasses; uses {@code null} for the 148 * default value. 149 */ 150 protected ElementKindVisitor() { 151 super(null); 152 } 153 154 /** 155 * Constructor for concrete subclasses; uses the argument for the 156 * default value. 157 * 158 * @param defaultValue the value to assign to {@link #DEFAULT_VALUE} 159 */ 160 protected ElementKindVisitor(R defaultValue) { 161 super(defaultValue); 162 } 163 } 164 165 @SupportedSourceVersion(RELEASE_10) 166 public static class ElementScanner<R, P> extends ElementScanner9<R, P> { 167 /** 168 * Constructor for concrete subclasses; uses {@code null} for the 169 * default value. 170 */ 171 protected ElementScanner(){ 172 super(null); 173 } 174 175 /** 176 * Constructor for concrete subclasses; uses the argument for the 177 * default value. 178 */ 179 protected ElementScanner(R defaultValue){ 180 super(defaultValue); 181 } 182 } 183 184 @SupportedSourceVersion(RELEASE_10) 185 public static class SimpleAnnotationValueVisitor<R, P> extends SimpleAnnotationValueVisitor9<R, P> { 186 /** 187 * Constructor for concrete subclasses; uses {@code null} for the 188 * default value. 189 */ 190 protected SimpleAnnotationValueVisitor() { 191 super(null); 192 } 193 194 /** 195 * Constructor for concrete subclasses; uses the argument for the 196 * default value. 197 * 198 * @param defaultValue the value to assign to {@link #DEFAULT_VALUE} 199 */ 200 protected SimpleAnnotationValueVisitor(R defaultValue) { 201 super(defaultValue); 202 } 203 } 204 205 @SupportedSourceVersion(RELEASE_10) 206 public static class SimpleElementVisitor<R, P> extends SimpleElementVisitor9<R, P> { 207 /** 208 * Constructor for concrete subclasses; uses {@code null} for the 209 * default value. 210 */ 211 protected SimpleElementVisitor(){ 212 super(null); 213 } 214 215 /** 216 * Constructor for concrete subclasses; uses the argument for the 217 * default value. 218 * 219 * @param defaultValue the value to assign to {@link #DEFAULT_VALUE} 220 */ 221 protected SimpleElementVisitor(R defaultValue){ 222 super(defaultValue); 223 } 224 } 225 226 @SupportedSourceVersion(RELEASE_10) 227 public static class SimpleTypeVisitor<R, P> extends SimpleTypeVisitor9<R, P> { 228 /** 229 * Constructor for concrete subclasses; uses {@code null} for the 230 * default value. 231 */ 232 protected SimpleTypeVisitor(){ 233 super(null); 234 } 235 236 /** 237 * Constructor for concrete subclasses; uses the argument for the 238 * default value. 239 * 240 * @param defaultValue the value to assign to {@link #DEFAULT_VALUE} 241 */ 242 protected SimpleTypeVisitor(R defaultValue){ 243 super(defaultValue); 244 } 245 } 246 247 @SupportedSourceVersion(RELEASE_10) 248 public static class TypeKindVisitor<R, P> extends TypeKindVisitor9<R, P> { 249 /** 250 * Constructor for concrete subclasses to call; uses {@code null} 251 * for the default value. 252 */ 253 protected TypeKindVisitor() { 254 super(null); 255 } 256 257 /** 258 * Constructor for concrete subclasses to call; uses the argument 259 * for the default value. 260 * 261 * @param defaultValue the value to assign to {@link #DEFAULT_VALUE} 262 */ 263 protected TypeKindVisitor(R defaultValue) { 264 super(defaultValue); 265 } 266 } 267 } | 93 94 protected void addExports(String moduleName, String... packageNames) { 95 for (String packageName : packageNames) { 96 try { 97 ModuleLayer layer = ModuleLayer.boot(); 98 Optional<Module> m = layer.findModule(moduleName); 99 if (!m.isPresent()) 100 throw new Error("module not found: " + moduleName); 101 m.get().addExports(packageName, getClass().getModule()); 102 } catch (Exception e) { 103 throw new Error("failed to add exports for " + moduleName + "/" + packageName); 104 } 105 } 106 } 107 108 /* 109 * The set of visitors below will directly extend the most recent 110 * corresponding platform visitor type. 111 */ 112 113 @SupportedSourceVersion(RELEASE_11) 114 public static abstract class AbstractAnnotationValueVisitor<R, P> extends AbstractAnnotationValueVisitor9<R, P> { 115 116 /** 117 * Constructor for concrete subclasses to call. 118 */ 119 protected AbstractAnnotationValueVisitor() { 120 super(); 121 } 122 } 123 124 @SupportedSourceVersion(RELEASE_11) 125 public static abstract class AbstractElementVisitor<R, P> extends AbstractElementVisitor9<R, P> { 126 /** 127 * Constructor for concrete subclasses to call. 128 */ 129 protected AbstractElementVisitor(){ 130 super(); 131 } 132 } 133 134 @SupportedSourceVersion(RELEASE_11) 135 public static abstract class AbstractTypeVisitor<R, P> extends AbstractTypeVisitor9<R, P> { 136 /** 137 * Constructor for concrete subclasses to call. 138 */ 139 protected AbstractTypeVisitor() { 140 super(); 141 } 142 } 143 144 @SupportedSourceVersion(RELEASE_11) 145 public static class ElementKindVisitor<R, P> extends ElementKindVisitor9<R, P> { 146 /** 147 * Constructor for concrete subclasses; uses {@code null} for the 148 * default value. 149 */ 150 protected ElementKindVisitor() { 151 super(null); 152 } 153 154 /** 155 * Constructor for concrete subclasses; uses the argument for the 156 * default value. 157 * 158 * @param defaultValue the value to assign to {@link #DEFAULT_VALUE} 159 */ 160 protected ElementKindVisitor(R defaultValue) { 161 super(defaultValue); 162 } 163 } 164 165 @SupportedSourceVersion(RELEASE_11) 166 public static class ElementScanner<R, P> extends ElementScanner9<R, P> { 167 /** 168 * Constructor for concrete subclasses; uses {@code null} for the 169 * default value. 170 */ 171 protected ElementScanner(){ 172 super(null); 173 } 174 175 /** 176 * Constructor for concrete subclasses; uses the argument for the 177 * default value. 178 */ 179 protected ElementScanner(R defaultValue){ 180 super(defaultValue); 181 } 182 } 183 184 @SupportedSourceVersion(RELEASE_11) 185 public static class SimpleAnnotationValueVisitor<R, P> extends SimpleAnnotationValueVisitor9<R, P> { 186 /** 187 * Constructor for concrete subclasses; uses {@code null} for the 188 * default value. 189 */ 190 protected SimpleAnnotationValueVisitor() { 191 super(null); 192 } 193 194 /** 195 * Constructor for concrete subclasses; uses the argument for the 196 * default value. 197 * 198 * @param defaultValue the value to assign to {@link #DEFAULT_VALUE} 199 */ 200 protected SimpleAnnotationValueVisitor(R defaultValue) { 201 super(defaultValue); 202 } 203 } 204 205 @SupportedSourceVersion(RELEASE_11) 206 public static class SimpleElementVisitor<R, P> extends SimpleElementVisitor9<R, P> { 207 /** 208 * Constructor for concrete subclasses; uses {@code null} for the 209 * default value. 210 */ 211 protected SimpleElementVisitor(){ 212 super(null); 213 } 214 215 /** 216 * Constructor for concrete subclasses; uses the argument for the 217 * default value. 218 * 219 * @param defaultValue the value to assign to {@link #DEFAULT_VALUE} 220 */ 221 protected SimpleElementVisitor(R defaultValue){ 222 super(defaultValue); 223 } 224 } 225 226 @SupportedSourceVersion(RELEASE_11) 227 public static class SimpleTypeVisitor<R, P> extends SimpleTypeVisitor9<R, P> { 228 /** 229 * Constructor for concrete subclasses; uses {@code null} for the 230 * default value. 231 */ 232 protected SimpleTypeVisitor(){ 233 super(null); 234 } 235 236 /** 237 * Constructor for concrete subclasses; uses the argument for the 238 * default value. 239 * 240 * @param defaultValue the value to assign to {@link #DEFAULT_VALUE} 241 */ 242 protected SimpleTypeVisitor(R defaultValue){ 243 super(defaultValue); 244 } 245 } 246 247 @SupportedSourceVersion(RELEASE_11) 248 public static class TypeKindVisitor<R, P> extends TypeKindVisitor9<R, P> { 249 /** 250 * Constructor for concrete subclasses to call; uses {@code null} 251 * for the default value. 252 */ 253 protected TypeKindVisitor() { 254 super(null); 255 } 256 257 /** 258 * Constructor for concrete subclasses to call; uses the argument 259 * for the default value. 260 * 261 * @param defaultValue the value to assign to {@link #DEFAULT_VALUE} 262 */ 263 protected TypeKindVisitor(R defaultValue) { 264 super(defaultValue); 265 } 266 } 267 } |