0%

字节码增强技术

字节码增强技术

图16 字节码增强技术

  • ASM
  • JavaAssist
  • ByteBuddy
  • CGLIB

https://juejin.cn/post/6844903970658320391

https://www.wwwbuild.net/E-MapReduce_Spark/22025.html

https://blog.csdn.net/junerli/article/details/112687385

Presto使用了一个基于ASM的字节码生成工具airlift-bytecode(facebook内部库)来进行字节码的构建

Spark 和 Flink 都是使用 Janino 来做codeGen的,
Presto是使用airlift-bytecode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// org.apache.flink.table.runtime.generated.CompileUtils#doCompile
private static <T> Class<T> doCompile(ClassLoader cl, String name, String code) {
checkNotNull(cl, "Classloader must not be null.");
CODE_LOG.debug("Compiling: {} \n\n Code:\n{}", name, code);
SimpleCompiler compiler = new SimpleCompiler();
compiler.setParentClassLoader(cl);
try {
compiler.cook(code);
} catch (Throwable t) {
System.out.println(addLineNumber(code));
throw new InvalidProgramException(
"Table program cannot be compiled. This is a bug. Please file an issue.", t);
}
try {
//noinspection unchecked
return (Class<T>) compiler.getClassLoader().loadClass(name);
} catch (ClassNotFoundException e) {
throw new RuntimeException("Can not load class " + name, e);
}
}

Spring如何实现AOP,请不要再说cglib了!
https://juejin.cn/post/6844903970658320391

Spring AOP原理分析一次看懂 - 知乎
https://zhuanlan.zhihu.com/p/36617574

Spring系列之AOP的原理及手动实现
https://juejin.cn/post/6844903744530808840

【Spring基础】CGLIB动态代理实现原理_yhl_jxy的博客-CSDN博客_cglib动态代理
https://blog.csdn.net/yhl_jxy/article/details/80633194

Spring源码剖析5:JDK和cglib动态代理原理详解 - SegmentFault 思否
https://segmentfault.com/a/1190000020178773

CGLIB(Code Generation Library) 介绍与原理 | 菜鸟教程
https://www.runoob.com/w3cnote/cglibcode-generation-library-intro.html

JDK动态代理生成class文件和cglib动态代理生成class文件_RainSun-CSDN博客_cglib生成的class文件
https://blog.csdn.net/u010811939/article/details/80763336

Java动态生成类以及动态添加属性 - 有梦就能实现 - 博客园
https://www.cnblogs.com/firstdream/p/10078673.html