JDK-7154822 : forward port fix for Bug 13645891 to JDK8 jcmd (1024 byte file size limit issue)
  • Type: Bug
  • Component: core-svc
  • Sub-Component: tools
  • Affected Version: 8
  • Priority: P5
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2012-03-19
  • Updated: 2013-04-30
  • Resolved: 2012-04-24
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.
7u6Fixed 8 b36Fixed
Related Reports
Relates :  
This is a "forward port" of the fix for Bug 13645891 in JRockit's JRCMD command to Oracle JDK's new jcmd command.

From 13645891
I created a jrcmd script and was using something like the below to run it:

jrcmd 12345 -f commands.txt

It turns out that the contents of the commands.txt file must not be more than roughly 256 bytes, otherwise jrcmd will return a cryptic error message (OS dependent, the below is what it looks like on Linux):

jrcmd 11052 -f commands.txt
java.io.IOException: Premature EOF
        at sun.tools.attach.LinuxVirtualMachine.execute(LinuxVirtualMachine.java:175)
        at jrockit.tools.jrcmd.JrCmd.executeCommandForPid(JrCmd.java:115)
        at jrockit.tools.jrcmd.JrCmd.main(JrCmd.java:90)

The reason for this is that the attach implementation in JRockit limits the attach operation commands to 256 characters (see attach_internal.h/MAX_ARG_LEN) and jrcmd sends the whole file contents as a single command to the VM. The actual check which bails out the execution can be found in attach.c:attachOperationSetArg called from attach_linux.c:read_request on Linux.

EVALUATION Fix is to break the input into individual lines and sent each one to the JVM one at a time. We still have a 1024-byte limit on the size of each line, but in practice I do not believe this will be an issue.