8055677: java/lang/instrument/RedefineBigClass.sh RetransformBigClass.sh start failing after JDK-8055012
authorsla
Thu, 21 Aug 2014 13:09:28 +0200
changeset 26193 09edb0e9f15a
parent 26192 33b90e93e3bf
child 26194 1570007fff27
8055677: java/lang/instrument/RedefineBigClass.sh RetransformBigClass.sh start failing after JDK-8055012 Summary: Write dcmd output to separate files so it does not confuse the output. Reviewed-by: ctornqvi, mgronlun
jdk/test/java/lang/instrument/NMTHelper.java
jdk/test/java/lang/instrument/RedefineBigClass.sh
jdk/test/java/lang/instrument/RetransformBigClass.sh
--- a/jdk/test/java/lang/instrument/NMTHelper.java	Thu Aug 21 12:23:20 2014 +0200
+++ b/jdk/test/java/lang/instrument/NMTHelper.java	Thu Aug 21 13:09:28 2014 +0200
@@ -21,8 +21,12 @@
  * questions.
  */
 
+import java.io.File;
+import java.io.FileWriter;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
+import java.util.Arrays;
+import java.util.stream.Collectors;
 import sun.management.ManagementFactoryHelper;
 import com.sun.management.DiagnosticCommandMBean;
 
@@ -53,14 +57,14 @@
         Object[] dcmdArgs = {args};
         String[] signature = {String[].class.getName()};
 
-        try {
-            System.out.print("> " + cmd + " ");
-            for (String s : args) {
-                System.out.print(s + " ");
-            }
-            System.out.println(":");
+        String cmdString = cmd + " " +
+            Arrays.stream(args).collect(Collectors.joining(" "));
+        File f = new File("dcmdoutput-" + cmd + "-" + System.currentTimeMillis() + ".txt");
+        System.out.println("Output from Dcmd '" + cmdString + "' is being written to file " + f);
+        try (FileWriter fw = new FileWriter(f)) {
+            fw.write("> " + cmdString + ":");
             String result = (String) dcmd.invoke(cmd, dcmdArgs, signature);
-            System.out.println(result);
+            fw.write(result);
             return result;
         } catch(Exception ex) {
             ex.printStackTrace();
--- a/jdk/test/java/lang/instrument/RedefineBigClass.sh	Thu Aug 21 12:23:20 2014 +0200
+++ b/jdk/test/java/lang/instrument/RedefineBigClass.sh	Thu Aug 21 13:09:28 2014 +0200
@@ -27,7 +27,7 @@
 # @author Daniel D. Daugherty
 #
 # @run shell MakeJAR3.sh RedefineBigClassAgent 'Can-Redefine-Classes: true'
-# @run build BigClass RedefineBigClassApp
+# @run build BigClass RedefineBigClassApp NMTHelper
 # @run shell/timeout=600 RedefineBigClass.sh
 #
 
--- a/jdk/test/java/lang/instrument/RetransformBigClass.sh	Thu Aug 21 12:23:20 2014 +0200
+++ b/jdk/test/java/lang/instrument/RetransformBigClass.sh	Thu Aug 21 13:09:28 2014 +0200
@@ -27,7 +27,7 @@
 # @author Daniel D. Daugherty
 #
 # @run shell MakeJAR4.sh RetransformBigClassAgent SimpleIdentityTransformer 'Can-Retransform-Classes: true'
-# @run build BigClass RetransformBigClassApp
+# @run build BigClass RetransformBigClassApp NMTHelper
 # @run shell/timeout=600 RetransformBigClass.sh
 #