8149729: [jittester] Replace all 'path1 +"/" + path2' with Paths::get
authoriignatyev
Thu, 28 Jun 2018 16:45:15 -0700
changeset 50907 39d27210c627
parent 50906 bc6cfa433862
child 50908 7c51db95ccb6
8149729: [jittester] Replace all 'path1 +"/" + path2' with Paths::get Reviewed-by: kvn
test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/ByteCodeGenerator.java
test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/JavaCodeGenerator.java
test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/TestsGenerator.java
test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/TypesParser.java
test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/jtreg/JitTesterDriver.java
--- a/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/ByteCodeGenerator.java	Fri Jun 29 01:09:29 2018 +0200
+++ b/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/ByteCodeGenerator.java	Thu Jun 28 16:45:15 2018 -0700
@@ -23,14 +23,14 @@
 
 package jdk.test.lib.jittester;
 
-import java.io.FileOutputStream;
+import jdk.test.lib.jittester.visitors.ByteCodeVisitor;
+
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.StandardOpenOption;
 import java.util.function.Function;
-import jdk.test.lib.jittester.visitors.ByteCodeVisitor;
 
 /**
  * Generates class files from IRTree
@@ -88,8 +88,8 @@
     }
 
     private void writeFile(String fileName, byte[] bytecode) {
-        try (FileOutputStream file = new FileOutputStream(generatorDir.resolve(fileName).toFile())) {
-            file.write(bytecode);
+        try {
+            Files.write(generatorDir.resolve(fileName), bytecode);
         } catch (IOException ex) {
             ex.printStackTrace();
         }
--- a/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/JavaCodeGenerator.java	Fri Jun 29 01:09:29 2018 +0200
+++ b/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/JavaCodeGenerator.java	Thu Jun 28 16:45:15 2018 -0700
@@ -23,7 +23,6 @@
 
 package jdk.test.lib.jittester;
 
-import java.io.File;
 import java.io.IOException;
 import java.util.function.Function;
 import jdk.test.lib.jittester.visitors.JavaCodeVisitor;
@@ -65,7 +64,9 @@
     }
 
     private void compileJavaFile(String mainClassName) {
-        String classPath = getRoot() + File.pathSeparator + generatorDir;
+        String classPath = getRoot().resolve(generatorDir)
+                                    .toAbsolutePath()
+                                    .toString();
         ProcessBuilder pb = new ProcessBuilder(JAVAC, "-cp", classPath,
                 generatorDir.resolve(mainClassName + ".java").toString());
         try {
--- a/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/TestsGenerator.java	Fri Jun 29 01:09:29 2018 +0200
+++ b/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/TestsGenerator.java	Thu Jun 28 16:45:15 2018 -0700
@@ -58,7 +58,9 @@
     }
 
     protected void generateGoldenOut(String mainClassName) {
-        String classPath = getRoot() + File.pathSeparator + generatorDir;
+        String classPath = getRoot().resolve(generatorDir)
+                                    .toAbsolutePath()
+                                    .toString();
         ProcessBuilder pb = new ProcessBuilder(JAVA, "-Xint", DISABLE_WARNINGS, "-Xverify",
                 "-cp", classPath, mainClassName);
         String goldFile = mainClassName + ".gold";
@@ -182,7 +184,10 @@
         for (String name : env) {
             String path = System.getenv(name);
             if (path != null) {
-                return path + "/bin/";
+                return Paths.get(path)
+                            .resolve("bin")
+                            .toAbsolutePath()
+                            .toString();
             }
         }
         return "";
--- a/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/TypesParser.java	Fri Jun 29 01:09:29 2018 +0200
+++ b/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/TypesParser.java	Thu Jun 28 16:45:15 2018 -0700
@@ -31,6 +31,7 @@
 import java.lang.reflect.Modifier;
 import java.nio.file.Files;
 import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;
@@ -207,7 +208,7 @@
         Asserts.assertNotNull(klassesFileName, "Classes input file name is null");
         Asserts.assertFalse(klassesFileName.isEmpty(), "Classes input file name is empty");
         List<String> klassNamesList = new ArrayList<>();
-        Path klassesFilePath = (new File(klassesFileName)).toPath();
+        Path klassesFilePath = Paths.get(klassesFileName);
         try {
             Files.lines(klassesFilePath).forEach(line -> {
                 line = line.trim();
@@ -223,7 +224,7 @@
             throw new Error("Error reading klasses file", ex);
         }
         List<Class<?>> klassesList = new ArrayList<>();
-        klassNamesList.stream().forEach(klassName -> {
+        klassNamesList.forEach(klassName -> {
             try {
                 klassesList.add(Class.forName(klassName));
             } catch (ClassNotFoundException ex) {
@@ -237,7 +238,7 @@
         Asserts.assertNotNull(methodsFileName, "Methods exclude input file name is null");
         Asserts.assertFalse(methodsFileName.isEmpty(), "Methods exclude input file name is empty");
         LinkedList<String> methodNamesList = new LinkedList<>();
-        Path klassesFilePath = (new File(methodsFileName)).toPath();
+        Path klassesFilePath = Paths.get(methodsFileName);
         try {
             Files.lines(klassesFilePath).forEach(line -> {
                 line = line.trim();
@@ -253,7 +254,7 @@
             throw new Error("Error reading exclude method file", ex);
         }
         Set<Executable> methodsList = new HashSet<>();
-        methodNamesList.stream().forEach(methodName -> {
+        methodNamesList.forEach(methodName -> {
             String[] klassAndNameAndSig = methodName.split("::");
             String klassName = klassAndNameAndSig[0].replaceAll("/", "\\.");
             String[] nameAndSig = klassAndNameAndSig[1].split("[\\(\\)]");
--- a/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/jtreg/JitTesterDriver.java	Fri Jun 29 01:09:29 2018 +0200
+++ b/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/jtreg/JitTesterDriver.java	Thu Jun 28 16:45:15 2018 -0700
@@ -24,15 +24,15 @@
 package jdk.test.lib.jittester.jtreg;
 
 import jdk.test.lib.Asserts;
+import jdk.test.lib.Utils;
 import jdk.test.lib.process.OutputAnalyzer;
 import jdk.test.lib.process.ProcessTools;
-import jdk.test.lib.Utils;
+
 import java.io.IOException;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.util.Arrays;
-import java.util.function.Predicate;
 import java.util.regex.Pattern;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;