equal
deleted
inserted
replaced
343 tb.writeJavaFiles(classpathSrc, |
343 tb.writeJavaFiles(classpathSrc, |
344 generateCheckAccessibleClass("cp.CP")); |
344 generateCheckAccessibleClass("cp.CP")); |
345 |
345 |
346 Files.createDirectories(classpathOut); |
346 Files.createDirectories(classpathOut); |
347 |
347 |
|
348 System.err.println("Compiling classpath-src files:"); |
348 new JavacTask(tb) |
349 new JavacTask(tb) |
349 .outdir(classpathOut) |
350 .outdir(classpathOut) |
350 .files(findJavaFiles(classpathSrc)) |
351 .files(findJavaFiles(classpathSrc)) |
351 .run() |
352 .run() |
352 .writeAll() |
353 .writeAll() |
358 tb.writeJavaFiles(automaticSrc, |
359 tb.writeJavaFiles(automaticSrc, |
359 generateCheckAccessibleClass("automatic.Automatic")); |
360 generateCheckAccessibleClass("automatic.Automatic")); |
360 |
361 |
361 Files.createDirectories(automaticOut); |
362 Files.createDirectories(automaticOut); |
362 |
363 |
|
364 System.err.println("Compiling automatic-src files:"); |
363 new JavacTask(tb) |
365 new JavacTask(tb) |
364 .outdir(automaticOut) |
366 .outdir(automaticOut) |
365 .files(findJavaFiles(automaticSrc)) |
367 .files(findJavaFiles(automaticSrc)) |
366 .run() |
368 .run() |
367 .writeAll() |
369 .writeAll() |
371 |
373 |
372 Files.createDirectories(modulePath); |
374 Files.createDirectories(modulePath); |
373 |
375 |
374 Path automaticJar = modulePath.resolve("automatic.jar"); |
376 Path automaticJar = modulePath.resolve("automatic.jar"); |
375 |
377 |
|
378 System.err.println("Creating automatic.jar:"); |
376 new JarTask(tb, automaticJar) |
379 new JarTask(tb, automaticJar) |
377 .baseDir(automaticOut) |
380 .baseDir(automaticOut) |
378 .files("automatic/Automatic.class") |
381 .files("automatic/Automatic.class") |
379 .run(); |
382 .run(); |
380 |
383 |
383 |
386 |
384 tb.writeJavaFiles(m1, |
387 tb.writeJavaFiles(m1, |
385 "module m1 { exports api; }", |
388 "module m1 { exports api; }", |
386 "package api; public class Api { public void test() { } }"); |
389 "package api; public class Api { public void test() { } }"); |
387 |
390 |
|
391 System.err.println("Compiling module-src files:"); |
388 new JavacTask(tb) |
392 new JavacTask(tb) |
389 .options("--module-source-path", moduleSrc.toString()) |
393 .options("--module-source-path", moduleSrc.toString()) |
390 .outdir(modulePath) |
394 .outdir(modulePath) |
391 .files(findJavaFiles(moduleSrc)) |
395 .files(findJavaFiles(moduleSrc)) |
392 .run() |
396 .run() |
397 |
401 |
398 for (String moduleInfo : MODULE_INFO_VARIANTS) { |
402 for (String moduleInfo : MODULE_INFO_VARIANTS) { |
399 for (String[] options : OPTIONS_VARIANTS) { |
403 for (String[] options : OPTIONS_VARIANTS) { |
400 index++; |
404 index++; |
401 |
405 |
402 System.err.println("running check: " + moduleInfo + "; " + Arrays.asList(options)); |
406 System.err.println("Running check: " + moduleInfo + "; " + Arrays.asList(options)); |
403 |
407 |
404 Path m2Runtime = base.resolve(index + "-runtime").resolve("m2"); |
408 Path m2Runtime = base.resolve(index + "-runtime").resolve("m2"); |
405 Path out = base.resolve(index + "-runtime").resolve("out").resolve("m2"); |
409 Path out = base.resolve(index + "-runtime").resolve("out").resolve("m2"); |
406 |
410 |
407 Files.createDirectories(out); |
411 Files.createDirectories(out); |
425 testClassNamed.append(" }\n" + |
429 testClassNamed.append(" }\n" + |
426 "}"); |
430 "}"); |
427 |
431 |
428 tb.writeJavaFiles(m2Runtime, moduleInfo, testClassNamed.toString()); |
432 tb.writeJavaFiles(m2Runtime, moduleInfo, testClassNamed.toString()); |
429 |
433 |
|
434 System.err.println("Compiling " + m2Runtime + " files:"); |
430 new JavacTask(tb) |
435 new JavacTask(tb) |
431 .options("--module-path", modulePath.toString()) |
436 .options("--module-path", modulePath.toString()) |
432 .outdir(out) |
437 .outdir(out) |
433 .files(findJavaFiles(m2Runtime)) |
438 .files(findJavaFiles(m2Runtime)) |
434 .run() |
439 .run() |
436 |
441 |
437 boolean success; |
442 boolean success; |
438 String output; |
443 String output; |
439 |
444 |
440 try { |
445 try { |
|
446 System.err.println("Running m2/test.Test:"); |
441 output = new JavaTask(tb) |
447 output = new JavaTask(tb) |
442 .vmOptions(augmentOptions(options, |
448 .vmOptions(augmentOptions(options, |
443 Collections.emptyList(), |
449 Collections.emptyList(), |
444 "--module-path", modulePath.toString() + File.pathSeparator + out.getParent().toString(), |
450 "--module-path", modulePath.toString() + File.pathSeparator + out.getParent().toString(), |
445 "--class-path", classpathOut.toString(), |
451 "--class-path", classpathOut.toString(), |
466 "--processor-path", System.getProperty("test.class.path"), |
472 "--processor-path", System.getProperty("test.class.path"), |
467 "-processor", CheckVisibleModule.class.getName(), |
473 "-processor", CheckVisibleModule.class.getName(), |
468 "-Aoutput=" + output, |
474 "-Aoutput=" + output, |
469 "-XDaccessInternalAPI=true" |
475 "-XDaccessInternalAPI=true" |
470 ) : Collections.emptyList(); |
476 ) : Collections.emptyList(); |
|
477 |
|
478 System.err.println("Compiling/processing m2 files:"); |
471 new JavacTask(tb) |
479 new JavacTask(tb) |
472 .options(augmentOptions(options, |
480 .options(augmentOptions(options, |
473 auxOptions, |
481 auxOptions, |
474 "--module-path", modulePath.toString(), |
482 "--module-path", modulePath.toString(), |
475 "--class-path", classpathOut.toString(), |
483 "--class-path", classpathOut.toString(), |
508 |
516 |
509 static { |
517 static { |
510 MODULES_TO_CHECK_TO_SAMPLE_CLASS.put("m1", "api.Api"); |
518 MODULES_TO_CHECK_TO_SAMPLE_CLASS.put("m1", "api.Api"); |
511 MODULES_TO_CHECK_TO_SAMPLE_CLASS.put("m2", "test.Test"); |
519 MODULES_TO_CHECK_TO_SAMPLE_CLASS.put("m2", "test.Test"); |
512 MODULES_TO_CHECK_TO_SAMPLE_CLASS.put("java.base", "java.lang.Object"); |
520 MODULES_TO_CHECK_TO_SAMPLE_CLASS.put("java.base", "java.lang.Object"); |
513 MODULES_TO_CHECK_TO_SAMPLE_CLASS.put("java.compiler", "javax.tools.ToolProvider"); |
|
514 MODULES_TO_CHECK_TO_SAMPLE_CLASS.put("jdk.compiler", "com.sun.tools.javac.Main"); |
|
515 }; |
521 }; |
516 |
522 |
517 @SupportedAnnotationTypes("*") |
523 @SupportedAnnotationTypes("*") |
518 @SupportedOptions("output") |
524 @SupportedOptions("output") |
519 public static final class CheckVisibleModule extends AbstractProcessor { |
525 public static final class CheckVisibleModule extends AbstractProcessor { |
571 return all.toArray(new String[0]); |
577 return all.toArray(new String[0]); |
572 } |
578 } |
573 |
579 |
574 private static final String[] MODULE_INFO_VARIANTS = { |
580 private static final String[] MODULE_INFO_VARIANTS = { |
575 "module m2 { exports test; }", |
581 "module m2 { exports test; }", |
576 "module m2 { requires m1; exports test; }", |
582 "module m2 { requires m1; exports test; }" |
577 "module m2 { requires jdk.compiler; exports test; }", |
|
578 }; |
583 }; |
579 |
584 |
580 private static final String[][] OPTIONS_VARIANTS = { |
585 private static final String[][] OPTIONS_VARIANTS = { |
581 {"--add-modules", "automatic"}, |
586 {"--add-modules", "automatic"}, |
582 {"--add-modules", "m1,automatic"}, |
587 {"--add-modules", "m1,automatic"}, |