Skip to content

li24361/java-agent-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

java-agent-demo

一个字节码增强的小demo 在test方法前后植入代码

使用方法

首先打包

mvn assembly:assembly target/下面会生成java-agent-demo-1.0-SNAPSHOT-jar-with-dependencies.jar

运行方法:

premain jvm 参数形式启动,运行此方法

启动参数需要添加 -javaagent:{你的路径}/java-agent-demo-1.0-SNAPSHOT-jar-with-dependencies.jar 运行启动com.lzh.RunJvm#main

agentmain 动态 attach 方式启动,运行此方法

启动com.lzh.RunJvm#main jps -l 查找到 ,举例

1427 com.lzh.RunJvm

修改com.lzh.AttachAgent里面进行id为1427(举例,实际会不同)

启动 com.lzh.AttachAgent#main

参考:

About

java探针小demo

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages