8055677: java/lang/instrument/RedefineBigClass.sh RetransformBigClass.sh start failing after JDK-8055012

Write dcmd output to separate files so it does not confuse the output.

Reviewed-by: ctornqvi, mgronlun
This commit is contained in:
Staffan Larsen 2014-08-21 13:09:28 +02:00
parent bc41f7d7e9
commit cde8258b65
3 changed files with 13 additions and 9 deletions

View File

@ -21,8 +21,12 @@
* questions. * questions.
*/ */
import java.io.File;
import java.io.FileWriter;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.Arrays;
import java.util.stream.Collectors;
import sun.management.ManagementFactoryHelper; import sun.management.ManagementFactoryHelper;
import com.sun.management.DiagnosticCommandMBean; import com.sun.management.DiagnosticCommandMBean;
@ -53,14 +57,14 @@ public class NMTHelper
Object[] dcmdArgs = {args}; Object[] dcmdArgs = {args};
String[] signature = {String[].class.getName()}; String[] signature = {String[].class.getName()};
try { String cmdString = cmd + " " +
System.out.print("> " + cmd + " "); Arrays.stream(args).collect(Collectors.joining(" "));
for (String s : args) { File f = new File("dcmdoutput-" + cmd + "-" + System.currentTimeMillis() + ".txt");
System.out.print(s + " "); System.out.println("Output from Dcmd '" + cmdString + "' is being written to file " + f);
} try (FileWriter fw = new FileWriter(f)) {
System.out.println(":"); fw.write("> " + cmdString + ":");
String result = (String) dcmd.invoke(cmd, dcmdArgs, signature); String result = (String) dcmd.invoke(cmd, dcmdArgs, signature);
System.out.println(result); fw.write(result);
return result; return result;
} catch(Exception ex) { } catch(Exception ex) {
ex.printStackTrace(); ex.printStackTrace();

View File

@ -27,7 +27,7 @@
# @author Daniel D. Daugherty # @author Daniel D. Daugherty
# #
# @run shell MakeJAR3.sh RedefineBigClassAgent 'Can-Redefine-Classes: true' # @run shell MakeJAR3.sh RedefineBigClassAgent 'Can-Redefine-Classes: true'
# @run build BigClass RedefineBigClassApp # @run build BigClass RedefineBigClassApp NMTHelper
# @run shell/timeout=600 RedefineBigClass.sh # @run shell/timeout=600 RedefineBigClass.sh
# #

View File

@ -27,7 +27,7 @@
# @author Daniel D. Daugherty # @author Daniel D. Daugherty
# #
# @run shell MakeJAR4.sh RetransformBigClassAgent SimpleIdentityTransformer 'Can-Retransform-Classes: true' # @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 # @run shell/timeout=600 RetransformBigClass.sh
# #