equal
deleted
inserted
replaced
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
20 * or visit www.oracle.com if you need additional information or have any |
20 * or visit www.oracle.com if you need additional information or have any |
21 * questions. |
21 * questions. |
22 */ |
22 */ |
23 |
23 |
|
24 /* |
|
25 * @test |
|
26 * @summary Tests sjavac basic functionality |
|
27 */ |
|
28 |
24 import java.util.*; |
29 import java.util.*; |
25 import java.io.*; |
30 import java.io.*; |
26 import java.net.*; |
31 import java.net.*; |
27 import java.nio.file.*; |
32 import java.nio.file.*; |
28 import java.nio.file.attribute.*; |
33 import java.nio.file.attribute.*; |
80 incrementalCompileAddNative(); |
85 incrementalCompileAddNative(); |
81 incrementalCompileChangeNative(); |
86 incrementalCompileChangeNative(); |
82 compileWithOverrideSource(); |
87 compileWithOverrideSource(); |
83 compileWithInvisibleSources(); |
88 compileWithInvisibleSources(); |
84 compileCircularSources(); |
89 compileCircularSources(); |
|
90 compileExcludingDependency(); |
85 |
91 |
86 delete(gensrc); |
92 delete(gensrc); |
87 delete(gensrc2); |
93 delete(gensrc2); |
88 delete(gensrc3); |
94 delete(gensrc3); |
89 delete(bin); |
95 delete(bin); |
|
96 delete(headers); |
90 } |
97 } |
91 |
98 |
92 void initialCompile() throws Exception { |
99 void initialCompile() throws Exception { |
93 System.out.println("\nInitial compile of gensrc."); |
100 System.out.println("\nInitial compile of gensrc."); |
94 System.out.println("----------------------------"); |
101 System.out.println("----------------------------"); |
379 "bin/gamma/C.class", |
386 "bin/gamma/C.class", |
380 "bin/javac_state"); |
387 "bin/javac_state"); |
381 delete(bin); |
388 delete(bin); |
382 } |
389 } |
383 |
390 |
|
391 /** |
|
392 * Tests compiling class A that depends on class B without compiling class B |
|
393 * @throws Exception If test fails |
|
394 */ |
|
395 void compileExcludingDependency() throws Exception { |
|
396 System.out.println("\nVerify that excluding classes from compilation but not from linking works."); |
|
397 System.out.println("---------------------------------------------------------------------------"); |
|
398 |
|
399 delete(gensrc); |
|
400 delete(bin); |
|
401 previous_bin_state = collectState(bin); |
|
402 |
|
403 populate(gensrc, |
|
404 "alfa/A.java", |
|
405 "package alfa; public class A { beta.B b; }", |
|
406 "beta/B.java", |
|
407 "package beta; public class B { }"); |
|
408 |
|
409 compile("-x", "beta", "-src", "gensrc", "-x", "alfa", "-sourcepath", "gensrc", |
|
410 "-d", "bin", "--server:portfile=testserver,background=false"); |
|
411 |
|
412 Map<String,Long> new_bin_state = collectState(bin); |
|
413 verifyThatFilesHaveBeenAdded(previous_bin_state, new_bin_state, |
|
414 "bin/alfa/A.class", |
|
415 "bin/javac_state"); |
|
416 } |
|
417 |
384 void removeFrom(Path dir, String... args) throws IOException { |
418 void removeFrom(Path dir, String... args) throws IOException { |
385 for (String filename : args) { |
419 for (String filename : args) { |
386 Path p = dir.resolve(filename); |
420 Path p = dir.resolve(filename); |
387 Files.delete(p); |
421 Files.delete(p); |
388 } |
422 } |
403 out.println(content); |
437 out.println(content); |
404 out.close(); |
438 out.close(); |
405 } |
439 } |
406 } |
440 } |
407 |
441 |
408 void delete(Path root) throws IOException { |
442 void delete(final Path root) throws IOException { |
409 if (!Files.exists(root)) return; |
443 if (!Files.exists(root)) return; |
410 Files.walkFileTree(root, new SimpleFileVisitor<Path>() { |
444 Files.walkFileTree(root, new SimpleFileVisitor<Path>() { |
411 @Override |
445 @Override |
412 public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException |
446 public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException |
413 { |
447 { |