206 loader = ucl; 207 } 208 209 File classesDir = new File(tempDir, "classes"); 210 classesDir.mkdirs(); 211 clean(classesDir); 212 213 List<String> opts = new ArrayList<String>(); 214 opts.add("-d"); 215 opts.add(classesDir.getPath()); 216 if (options != null) 217 opts.addAll(options); 218 219 if (procFiles.size() > 0) { 220 List<String> pOpts = new ArrayList<>(Arrays.asList("-d", classesDir.getPath())); 221 222 // hack to automatically add exports; a better solution would be to grep the 223 // source for import statements or a magic comment 224 for (File pf: procFiles) { 225 if (pf.getName().equals("CreateBadClassFile.java")) { 226 pOpts.add("-XaddExports:jdk.jdeps/com.sun.tools.classfile=ALL-UNNAMED"); 227 } 228 } 229 230 new Jsr199Compiler(verbose).run(null, null, false, pOpts, procFiles); 231 opts.add("-classpath"); // avoid using -processorpath for now 232 opts.add(classesDir.getPath()); 233 createAnnotationServicesFile(classesDir, procFiles); 234 } else if (options != null) { 235 int i = options.indexOf("-processor"); 236 // check for built-in anno-processor(s) 237 if (i != -1 && options.get(i + 1).equals("DocCommentProcessor")) { 238 opts.add("-classpath"); 239 opts.add(System.getProperty("test.classes")); 240 } 241 } 242 243 List<File> files = srcFiles; 244 245 if (srcPathDir != null) { 246 opts.add("-sourcepath"); 247 opts.add(srcPathDir.getPath()); 248 } 249 250 if (moduleSourcePathDir != null) { 251 opts.add("-modulesourcepath"); 252 opts.add(moduleSourcePathDir.getPath()); 253 files = moduleSourcePathFiles; 254 } 255 256 if (additionalFiles.size() > 0) { 257 List<String> sOpts = Arrays.asList("-d", classesDir.getPath()); 258 new Jsr199Compiler(verbose).run(null, null, false, sOpts, additionalFiles); 259 } 260 261 try { 262 Compiler c = Compiler.getCompiler(runOpts, verbose); 263 c.run(out, keys, raw, opts, files); 264 } catch (IllegalArgumentException e) { 265 if (out != null) { 266 out.println("Invalid value for run tag: " + runOpts); 267 } 268 } 269 } 270 271 void createAnnotationServicesFile(File dir, List<File> procFiles) throws IOException { | 206 loader = ucl; 207 } 208 209 File classesDir = new File(tempDir, "classes"); 210 classesDir.mkdirs(); 211 clean(classesDir); 212 213 List<String> opts = new ArrayList<String>(); 214 opts.add("-d"); 215 opts.add(classesDir.getPath()); 216 if (options != null) 217 opts.addAll(options); 218 219 if (procFiles.size() > 0) { 220 List<String> pOpts = new ArrayList<>(Arrays.asList("-d", classesDir.getPath())); 221 222 // hack to automatically add exports; a better solution would be to grep the 223 // source for import statements or a magic comment 224 for (File pf: procFiles) { 225 if (pf.getName().equals("CreateBadClassFile.java")) { 226 pOpts.add("--add-exports=jdk.jdeps/com.sun.tools.classfile=ALL-UNNAMED"); 227 } 228 } 229 230 new Jsr199Compiler(verbose).run(null, null, false, pOpts, procFiles); 231 opts.add("-classpath"); // avoid using -processorpath for now 232 opts.add(classesDir.getPath()); 233 createAnnotationServicesFile(classesDir, procFiles); 234 } else if (options != null) { 235 int i = options.indexOf("-processor"); 236 // check for built-in anno-processor(s) 237 if (i != -1 && options.get(i + 1).equals("DocCommentProcessor")) { 238 opts.add("-classpath"); 239 opts.add(System.getProperty("test.classes")); 240 } 241 } 242 243 List<File> files = srcFiles; 244 245 if (srcPathDir != null) { 246 opts.add("-sourcepath"); 247 opts.add(srcPathDir.getPath()); 248 } 249 250 if (moduleSourcePathDir != null) { 251 opts.add("--module-source-path"); 252 opts.add(moduleSourcePathDir.getPath()); 253 files = moduleSourcePathFiles; 254 } 255 256 if (additionalFiles.size() > 0) { 257 List<String> sOpts = Arrays.asList("-d", classesDir.getPath()); 258 new Jsr199Compiler(verbose).run(null, null, false, sOpts, additionalFiles); 259 } 260 261 try { 262 Compiler c = Compiler.getCompiler(runOpts, verbose); 263 c.run(out, keys, raw, opts, files); 264 } catch (IllegalArgumentException e) { 265 if (out != null) { 266 out.println("Invalid value for run tag: " + runOpts); 267 } 268 } 269 } 270 271 void createAnnotationServicesFile(File dir, List<File> procFiles) throws IOException { |