< prev index next >

test/hotspot/jtreg/runtime/8176717/TestInheritFD.java

8205054: Could not find "lsof" on test machine
Reviewed-by: goetz, dholmes
 
     static boolean isWindows() {
         return getProperty("os.name").toLowerCase().contains("win");
     }
 
+    static Optional<String[]> lsofCommandCache = stream(new String[][]{
+            {"/usr/bin/lsof", "-p"},
+            {"/usr/sbin/lsof", "-p"},
+            {"/bin/lsof", "-p"},
+            {"/sbin/lsof", "-p"},
+            {"/usr/local/bin/lsof", "-p"},
+            {"/usr/bin/pfiles", "-F"}}) // Solaris
+        .filter(args -> new File(args[0]).exists())
+        .findFirst();
+
     static Optional<String[]> lsofCommand() {
-        return stream(new String[][]{
-                {"/usr/bin/lsof", "-p"},
-                {"/usr/sbin/lsof", "-p"},
-                {"/bin/lsof", "-p"},
-                {"/sbin/lsof", "-p"},
-                {"/usr/local/bin/lsof", "-p"},
-                {"/usr/bin/pfiles", "-F"}}) // Solaris
-            .filter(args -> new File(args[0]).exists())
-            .findFirst();
+        return lsofCommandCache;
     }
 
     static Collection<String> outputContainingFilenames() {
         long pid = ProcessHandle.current().pid();
 
    
< prev index next >