当前位置:网站首页>Generate Class bytecode files with Asm
Generate Class bytecode files with Asm
2022-07-29 15:03:00 【programmer greens】
一、背景
This is actually a series,It's all about how to dynamically change code at execution time,从动态代理、到Javaassist,然后到Asm,All to do the same thing.
1、Java代理
相对于Javassist,Asmis directly generated binaryClass文件,效率会更高,But writing code is particularly tedious.
二、AsmSome important class descriptions
1、ClassVistor接口的两个子类,ClassWriter和ClassReader,一个用来生成Class文件,一个用来写Class文件.If the modification already existsClass,你需要先使用ClassReader来分析Class文件.
2、MethodVistor类
visitCode:ASM开始扫描这个方法
visitMaxs(maxStack, maxLocals); This code uses at most one heap element 和一个 局部变量
visitEnd() 输出完成.
visitVarInsn:Access to local is a quantity.
三、用Asm生成HelloWorld例子

This syntax is still difficult to write,It took a long time to successfully outputHelloWorld,可以在Eclipse或IDEA中安装bytecodecan check oneClass文件的字节码,Then modify the code with reference to the bytecode file.
边栏推荐
- Shared memory - shmget filling holes
- Linux installation of MySQL (super detailed)
- 超好用的PC端录屏软件推荐
- 工业设备数字孪生技术,解决方案系统平台案例
- Based on domestic, link global | schneider electric "industrial SI alliance partners hand in hand" to the industry in the future
- 一篇适合新手的深度学习综述!
- RAMAN CONFIGURE 命令都能实现哪些功能
- Interfaces and Abstractions
- 为什么 ThreadLocal 可以做到线程隔离?
- 兆骑科创赛事活动承办,项目路演,人才引进平台
猜你喜欢

极市直播丨严彬-Unicorn:走向目标跟踪的大一统(ECCV2022 Oral)

xss内容总结

Violence recursion to dynamic programming 02 (very clever game of CARDS)

测试时间的评估:开发时间的1/3~1/2

The reason for Apple's official price reduction has been found, and it is also facing declining sales and even inventory problems

基于Flink CDC打通数据实时入湖

打卡广汽本田喜悦安全驾驶中心,体验最刁钻的场地训练

kubernetes中正strace etcd

ArcGIS Molder Builder模型构建器基本知识

WOLFLAB一方老师带你解读虚拟云网络《VMware NSX-T卷2》-1
随机推荐
正则、grep/egrep、sed、awk
超好用的PC端录屏软件推荐
力扣之顺序表
关于内部类
回放线上流量利器-GoReplay
如何编辑CAD图库里的图纸
Replay Online Traffic Tool - GoReplay
工业设备数字孪生技术,解决方案系统平台案例
没遇到过这三个问题都不好意思说用过Redis
【LeetCode】350. 两个数组的交集 II
广州市应急管理局发布夏季危化品十大安全风险
Linux安装MySQL(超详细)
立足本土,链接全球 | 施耐德电气“工业SI同盟”携手伙伴共赴未来工业
Realization of Online Chat System Based on SSM
rosbag data plotting MATLAB
Work Efficiency - Fifteen minutes allows you to quickly learn Markdown syntax to proficient in typesetting practice notes
广州消防:高温天气火灾频发 消防安全不容忽视
基于C语言实现一个社交系统
Guangzhou Emergency Management Bureau released the top ten safety risks of hazardous chemicals in summer
MySQL索引常见面试题(2022版)