< prev index next >
src/jdk.jcmd/share/classes/sun/tools/jinfo/JInfo.java
Print this page
rev 55734 : 8227868: jinfo and jstack can fail converting UTF8 output to strings
Reviewed-by:
@@ -28,14 +28,14 @@
import java.io.IOException;
import java.io.InputStream;
import java.util.Collection;
import com.sun.tools.attach.VirtualMachine;
-import com.sun.tools.attach.VirtualMachineDescriptor;
import sun.tools.attach.HotSpotVirtualMachine;
import sun.tools.common.ProcessArgumentMatcher;
+import sun.tools.common.PrintStreamPrinter;
/*
* This class is the main class for the JInfo utility. It parses its arguments
* and decides if the command should be satisfied using the VM attach mechanism
* or an SA tool.
@@ -201,21 +201,11 @@
}
}
// Read the stream from the target VM until EOF, then detach
private static void drain(VirtualMachine vm, InputStream in) throws IOException {
- // read to EOF and just print output
- byte b[] = new byte[256];
- int n;
- do {
- n = in.read(b);
- if (n > 0) {
- String s = new String(b, 0, n, "UTF-8");
- System.out.print(s);
- }
- } while (n > 0);
- in.close();
+ PrintStreamPrinter.drainUTF8(in, System.out);
vm.detach();
}
private static void checkForUnsupportedOptions(String[] args) {
// Check arguments for -F, and non-numeric value
< prev index next >