langtools/test/tools/sjavac/NoState.java
changeset 33555 c34ba9fa96ac
parent 32799 ee577901f4bb
child 34473 5f7202c2125d
equal deleted inserted replaced
33554:d29aff18b2f6 33555:c34ba9fa96ac
    34  * @run main Wrapper NoState
    34  * @run main Wrapper NoState
    35  */
    35  */
    36 
    36 
    37 import com.sun.tools.javac.util.Assert;
    37 import com.sun.tools.javac.util.Assert;
    38 
    38 
    39 import java.util.*;
    39 import java.io.IOException;
    40 import java.nio.file.*;
    40 import java.nio.file.*;
       
    41 import java.util.stream.Stream;
    41 
    42 
    42 public class NoState extends SJavacTester {
    43 public class NoState extends SJavacTester {
    43     public static void main(String... args) throws Exception {
    44     public static void main(String... args) throws Exception {
    44         new NoState().run();
    45         new NoState().run();
    45     }
    46     }
    55 
    56 
    56         // Make sure file was compiled
    57         // Make sure file was compiled
    57         Assert.check(Files.exists(BIN.resolve("pkg/A.class")));
    58         Assert.check(Files.exists(BIN.resolve("pkg/A.class")));
    58 
    59 
    59         // Make sure we have no other files (such as a javac_state file) in the bin directory
    60         // Make sure we have no other files (such as a javac_state file) in the bin directory
    60         Assert.check(Files.list(BIN).count() == 1);
    61         Assert.check(countPathsInDir(BIN) == 1);
    61         Assert.check(Files.list(BIN.resolve("pkg")).count() == 1);
    62         Assert.check(countPathsInDir(BIN.resolve("pkg")) == 1);
       
    63     }
       
    64 
       
    65     private long countPathsInDir(Path dir) throws IOException {
       
    66         try (Stream<Path> files = Files.list(dir)) {
       
    67             return files.count();
       
    68         }
    62     }
    69     }
    63 }
    70 }