javainstrumentsjavaagents

attach failed with error: java.io.IOException: Premature EOF


while I try to attach a process with code like:

vm = VirtualMachine.attach(pid);
vm.loadAgent(attachJarPath, properties);

I got this error:

java.io.IOException: Premature EOF
at sun.tools.attach.HotSpotVirtualMachine.readInt(HotSpotVirtualMachine.java:248)
at sun.tools.attach.LinuxVirtualMachine.execute(LinuxVirtualMachine.java:199)
at sun.tools.attach.HotSpotVirtualMachine.loadAgentLibrary(HotSpotVirtualMachine.java:58)
at sun.tools.attach.HotSpotVirtualMachine.loadAgentLibrary(HotSpotVirtualMachine.java:79)
at sun.tools.attach.HotSpotVirtualMachine.loadAgent(HotSpotVirtualMachine.java:103)

what can i do to fix this error?


Solution

  • I guess I've found the reason: the paratemers of "properties" transfer to aim JVM cannot be too long in: vm.loadAgent(attachJarPath, properties); because of the limit of attach Ti support;

    you can use a file to transfer your data