40
41 Path root = Paths.get(IncCompInheritance.class.getSimpleName() + "Test");
42 Path src = root.resolve("src");
43 Path classes = root.resolve("classes");
44
45 // Prep source files: A <- B <- C
46 String a = "package pkga; public class A { public void m() {} }";
47 String b = "package pkgb; public class B extends pkga.A {}";
48 String c = "package pkgc; public class C extends pkgb.B {{ new pkgb.B().m(); }}";
49 toolbox.writeFile(src.resolve("pkga/A.java"), a);
50 toolbox.writeFile(src.resolve("pkgb/B.java"), b);
51 toolbox.writeFile(src.resolve("pkgc/C.java"), c);
52
53 // Initial compile (should succeed)
54 String server = "--server:portfile=testserver,background=false";
55 int rc1 = compile(server, "-d", classes, src);
56 if (rc1 != 0)
57 throw new AssertionError("Compilation failed unexpectedly");
58
59 // Remove method A.m
60 String aModified = "package pkga; public class A { }";
61 toolbox.writeFile(src.resolve("pkga/A.java"), aModified);
62
63 // Incremental compile (C should now be recompiled even though it
64 // depends on A only through inheritance via B).
65 // Since A.m is removed, this should fail.
66 int rc2 = compile(server, "-d", classes, src);
67 if (rc2 == 0)
68 throw new AssertionError("Compilation succeeded unexpectedly");
69 }
70 }
|
40
41 Path root = Paths.get(IncCompInheritance.class.getSimpleName() + "Test");
42 Path src = root.resolve("src");
43 Path classes = root.resolve("classes");
44
45 // Prep source files: A <- B <- C
46 String a = "package pkga; public class A { public void m() {} }";
47 String b = "package pkgb; public class B extends pkga.A {}";
48 String c = "package pkgc; public class C extends pkgb.B {{ new pkgb.B().m(); }}";
49 toolbox.writeFile(src.resolve("pkga/A.java"), a);
50 toolbox.writeFile(src.resolve("pkgb/B.java"), b);
51 toolbox.writeFile(src.resolve("pkgc/C.java"), c);
52
53 // Initial compile (should succeed)
54 String server = "--server:portfile=testserver,background=false";
55 int rc1 = compile(server, "-d", classes, src);
56 if (rc1 != 0)
57 throw new AssertionError("Compilation failed unexpectedly");
58
59 // Remove method A.m
60 Thread.sleep(1000); // Make sure we get a new timestamp
61 String aModified = "package pkga; public class A { }";
62 toolbox.writeFile(src.resolve("pkga/A.java"), aModified);
63
64 // Incremental compile (C should now be recompiled even though it
65 // depends on A only through inheritance via B).
66 // Since A.m is removed, this should fail.
67 int rc2 = compile(server, "-d", classes, src);
68 if (rc2 == 0)
69 throw new AssertionError("Compilation succeeded unexpectedly");
70 }
71 }
|