用java -javagent:E:\workspace7\myASM\src\test\MyAgent.jar运行后,提示下面的异常:
Error occurred during initialization of VM
agent library failed to init: instrument
Error opening zip file or JAR manifest missing : E:\workspace7\myASM\src\test\MyAgent.jar
网上搜了半天,也没有找到关于instrumentation的这类异常。后来在MyAgent.jar包的MANIFEST.MF中,发现
Manifest-Version: 1.0
Premain-Class: com.taobao.MyAgent
Can-Redefine-Classes: true
Can-Retransform-Classes: true
Agent-Class: com.taobao.MyAgent
“:”后面必须有个空格,如果没有空格就是提示这个错误。