--- old/test/tools/sjavac/SJavac.java 2014-08-09 00:28:51.323753426 +0200 +++ new/test/tools/sjavac/SJavac.java 2014-08-09 00:28:51.203756907 +0200 @@ -25,7 +25,7 @@ /* * @test * @summary Test all aspects of sjavac. - * @bug 8004658 8042441 8042699 8054461 8054474 + * @bug 8004658 8042441 8042699 8054461 8054474 8054717 * * @build Wrapper * @run main Wrapper SJavac @@ -64,6 +64,7 @@ // Where to put compiled classes. Path bin; + Path bin2; // Where to put c-header files. Path headers; @@ -72,6 +73,7 @@ // Remember the previous bin and headers state here. Map previous_bin_state; + Map previous_bin2_state; Map previous_headers_state; public void test() throws Exception { @@ -79,12 +81,14 @@ gensrc2 = defaultfs.getPath("gensrc2"); gensrc3 = defaultfs.getPath("gensrc3"); bin = defaultfs.getPath("bin"); + bin2 = defaultfs.getPath("bin2"); headers = defaultfs.getPath("headers"); Files.createDirectory(gensrc); Files.createDirectory(gensrc2); Files.createDirectory(gensrc3); Files.createDirectory(bin); + Files.createDirectory(bin2); Files.createDirectory(headers); initialCompile(); @@ -99,6 +103,7 @@ compileCircularSources(); compileExcludingDependency(); incrementalCompileTestFullyQualifiedRef(); + compileTestingClasspathPubapis(); compileWithAtFile(); testStateDir(); @@ -466,6 +471,69 @@ } /** + * Tests that we track the pubapis of classes on the classpath. + * @throws Exception If test fails + */ + void compileTestingClasspathPubapis() throws Exception { + System.out.println("\nTest pubapi changes of classes on the classpath."); + System.out.println("--------------------------------------------------"); + + delete(gensrc); + delete(gensrc2); + delete(bin); + delete(bin2); + + populate(gensrc, + "alfa/omega/A.java", + "package alfa.omega; import beta.B; public class A { B b; }", + "beta/B.java", + "package beta; public class B { }"); + + populate(gensrc2, + "gamma/C.java", + "package gamma; import alfa.omega.A; public class C { A a; }"); + System.out.println("Compiling bin..."); + compile("-src", "gensrc", "-d", "bin", "--server:portfile=testserver,background=false"); + System.out.println("Compiling bin2..."); + compile("-classpath", "bin", "-src", "gensrc2", "-d", "bin2", "--server:portfile=testserver,background=false"); + + previous_bin2_state = collectState(bin2); + populate(gensrc, + "alfa/omega/AA.java", + "package alfa.omega; public class AA { }"); + + System.out.println("Compiling bin again..."); + compile("-src", "gensrc", "-d", "bin", "--server:portfile=testserver,background=false"); + System.out.println("Compiling bin2 again..."); + compile("-classpath", "bin", "-src", "gensrc2", "-d", "bin2", "--server:portfile=testserver,background=false"); + + Map new_bin2_state = collectState(bin2); + // Adding the class AA to alfa.A does not change the pubapi of the classes in alfa.A that + // is actually used. Thus there should be no change of bin2. If alfa.A had been inside a jar + // file, then bin2/javac_state would have been updated with a new timestamp for the jar. + verifyNewerFiles(previous_bin2_state, new_bin2_state, + "bin2/javac_state"); + + // Now modify pubapi of A + previous_bin2_state = collectState(bin2); + populate(gensrc, + "alfa/omega/A.java", + "package alfa.omega; import beta.B; public class A { B b; public int a; }"); + + System.out.println("Compiling bin again..."); + compile("-src", "gensrc", "-d", "bin", "--server:portfile=testserver,background=false"); + System.out.println("Compiling bin2 again"); + compile("-classpath", "bin", "-src", "gensrc2", "-d", "bin2", "--server:portfile=testserver,background=false"); + + new_bin2_state = collectState(bin2); + // Check that C was really recompiled due to the change in A:s pubapi. + verifyNewerFiles(previous_bin2_state, new_bin2_state, + "bin2/gamma/C.class", + "bin2/javac_state"); + + } + + /** * Tests @atfile * @throws Exception If test fails */