< prev index next >

test/jdk/tools/jlink/multireleasejar/JLinkMultiReleaseJarTest.java

Print this page

        

@@ -50,11 +50,13 @@
 import java.lang.module.ModuleDescriptor;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.nio.file.StandardCopyOption;
+import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.List;
 import java.util.Set;
 import java.util.jar.JarFile;
 import java.util.spi.ToolProvider;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;

@@ -132,17 +134,18 @@
         args[1] = "m1-logging.jar";
         JAR_TOOL.run(System.out, System.err, args);
     }
 
     private void javac(Path source, Path destination, String srcpath) throws IOException {
-        String[] args = Stream.concat(
-                Stream.of("-d", destination.toString(), "--module-source-path", srcpath),
-                Files.walk(source)
-                        .map(Path::toString)
+        List<String> args = new ArrayList<>(List.of("-d", destination.toString(), "--module-source-path", srcpath));
+        try (Stream<Path> pathStream = Files.walk(source)) {
+            pathStream.map(Path::toString)
                         .filter(s -> s.endsWith(".java"))
-        ).toArray(String[]::new);
-        int rc = JAVAC_TOOL.run(System.out, System.err, args);
+                      .forEach(args::add);
+        }
+
+        int rc = JAVAC_TOOL.run(System.out, System.err, args.toArray(new String[0]));
         Assert.assertEquals(rc, 0);
     }
 
     @Test
     public void basicTest() throws Throwable {
< prev index next >