This is a "forward port" of the fix for Bug 13645891 in JRockit's JRCMD command to Oracle JDK's new jcmd command.
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
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.