JDK-7167157 : jcmd command file parsing does not respect the "stop" command
  • Type: Bug
  • Component: core-svc
  • Sub-Component: tools
  • Affected Version: 7u6,8
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2012-05-08
  • Updated: 2012-06-15
  • Resolved: 2012-06-15
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
7u6 b12Fixed 8Fixed
Related Reports
Relates :  
$ echo VM.version > file
$ echo stop >> file
$ echo VM.version >> file
$ jcmd <pid> -f file
will give two printouts of VM version despite the "stop" command.

This appears to be a regression in the "jcmd" binary, 8-b37 and 8-b36 have this behavior but 8-b28 and 7u4-b20 does not.

EVALUATION Fix: diff --git a/src/share/classes/sun/tools/jcmd/JCmd.java b/src/share/classes/sun/tools/jcmd/JCmd.java --- a/src/share/classes/sun/tools/jcmd/JCmd.java +++ b/src/share/classes/sun/tools/jcmd/JCmd.java @@ -144,6 +144,9 @@ HotSpotVirtualMachine hvm = (HotSpotVirtualMachine) vm; String lines[] = command .split("\\n"); for (String line : lines) { + if (line.startsWith("stop")) { + break; + } try (InputStream in = hvm.executeJCmd(line);) { // read to EOF and just print output byte b[] = new byte[256];

EVALUATION This is an unfortunate artifact of the fix for 7154822. Previously all lines in the command file were sent to the JVM as one string, but the size limit was 1024 bytes so this was changed to sending one line at a time. Problem with this is that the jcmd utility now keeps sending commands even if it has encountered a 'stop'.