312 .classes("package pkg2; /** Class B */ public class B { /** Field f */ public pkg1.A f; }") |
313 .classes("package pkg2; /** Class B */ public class B { /** Field f */ public pkg1.A f; }") |
313 .write(src); |
314 .write(src); |
314 execTask("--module-source-path", src.toString(), |
315 execTask("--module-source-path", src.toString(), |
315 "--module-path", modulePath.toString(), |
316 "--module-path", modulePath.toString(), |
316 "--add-exports", "m1/pkg1=m2", |
317 "--add-exports", "m1/pkg1=m2", |
317 "--module", "m2"); |
|
318 checkModulesSpecified("m2"); |
|
319 checkPackagesIncluded("pkg2"); |
|
320 checkMembersSelected("pkg2.B.f"); |
|
321 } |
|
322 |
|
323 @Test |
|
324 public void testPatchModuleOption(Path base) throws Exception { |
|
325 Path src = base.resolve("src"); |
|
326 Path modulePath = base.resolve("modules"); |
|
327 Path patchPath = base.resolve("patch"); |
|
328 |
|
329 ModuleBuilder mb1 = new ModuleBuilder(tb, "m1"); |
|
330 mb1.comment("Module on module path.") |
|
331 .exports("pkg1") |
|
332 .classes("package pkg1; /** Class A */ public class A { }") |
|
333 .build(modulePath); |
|
334 |
|
335 tb.writeJavaFiles(patchPath, "package pkg1; /** Class A */ public class A { public static int k; }"); |
|
336 new JavacTask(tb) |
|
337 .files(patchPath.resolve("pkg1/A.java")) |
|
338 .run(); |
|
339 |
|
340 ModuleBuilder mb2 = new ModuleBuilder(tb, "m2"); |
|
341 mb2.comment("The second module.") |
|
342 .exports("pkg2") |
|
343 .requires("m1") |
|
344 .classes("package pkg2; /** Class B */ public class B { /** Field f */ public int f = pkg1.A.k; }") |
|
345 .write(src); |
|
346 execTask("--module-source-path", src.toString(), |
|
347 "--patch-module", "m1=" + patchPath.toString(), |
|
348 "--module-path", modulePath.toString(), |
|
349 "--module", "m2"); |
318 "--module", "m2"); |
350 checkModulesSpecified("m2"); |
319 checkModulesSpecified("m2"); |
351 checkPackagesIncluded("pkg2"); |
320 checkPackagesIncluded("pkg2"); |
352 checkMembersSelected("pkg2.B.f"); |
321 checkMembersSelected("pkg2.B.f"); |
353 } |
322 } |
548 "--expand-requires", "all"); |
517 "--expand-requires", "all"); |
549 |
518 |
550 assertMessagePresent("javadoc: error - module MIA not found"); |
519 assertMessagePresent("javadoc: error - module MIA not found"); |
551 } |
520 } |
552 |
521 |
|
522 @Test |
|
523 public void testSingleModuleOptionWithSourcePath(Path base) throws Exception { |
|
524 Path src = base.resolve("src"); |
|
525 Path mod = createSimpleModule(src, "m1"); |
|
526 execTask("--source-path", mod.toString(), |
|
527 "--module", "m1"); |
|
528 checkModulesSpecified("m1"); |
|
529 checkPackagesIncluded("p"); |
|
530 checkTypesIncluded("p.C"); |
|
531 } |
|
532 |
|
533 @Test |
|
534 public void testSingleModuleOptionWithMissingModuleInSourcePath(Path base) throws Exception { |
|
535 Path src = base.resolve("src"); |
|
536 Path mod = createSimpleModule(src, "m1"); |
|
537 execNegativeTask("--source-path", mod.toString(), |
|
538 "--module", "m2"); |
|
539 assertMessagePresent("source path does not contain module m2"); |
|
540 } |
|
541 |
|
542 @Test |
|
543 public void testMultipleModuleOptionWithSourcePath(Path base) throws Exception { |
|
544 Path src = base.resolve("src"); |
|
545 Path mod = createSimpleModule(src, "m1"); |
|
546 execNegativeTask("--source-path", mod.toString(), |
|
547 "--module", "m1,m2,m3"); |
|
548 assertMessagePresent("cannot use source path for multiple modules m1, m2, m3"); |
|
549 } |
|
550 |
|
551 @Test |
|
552 public void testSingleModuleOptionWithNoModuleOnSourcePath(Path base) throws Exception { |
|
553 Path src = base.resolve("src"); |
|
554 Path mod1 = Paths.get(src.toString(), "m1"); |
|
555 execNegativeTask("--source-path", mod1.toString(), |
|
556 "--module", "m1"); |
|
557 assertMessagePresent("module m1 not found on source path"); |
|
558 } |
|
559 |
|
560 Path createSimpleModule(Path src, String mname) throws IOException { |
|
561 Path mpath = Paths.get(src.toString(), mname); |
|
562 tb.writeJavaFiles(mpath, |
|
563 "module " + mname + " { exports p; }", |
|
564 "package p; public class C { }"); |
|
565 return mpath; |
|
566 } |
|
567 |
553 void createAuxiliaryModules(Path src) throws IOException { |
568 void createAuxiliaryModules(Path src) throws IOException { |
554 |
569 |
555 new ModuleBuilder(tb, "J") |
570 new ModuleBuilder(tb, "J") |
556 .comment("The J module.") |
571 .comment("The J module.") |
557 .exports("openJ") |
572 .exports("openJ") |