#Fastclass 代理 cglib ASM #代理类型:对象实现接口,使用 JDK动态代理 对象没有实现接口,使用 Cglib动态代理 。jdk8之后,jdk动态代理速度比cglib快(不那么重要纠结了)。 可以强制使用CGlib ,配置 @EnableAspectJAutoProxy(proxyTargetClass = true) 或者 spring.aop.proxy-target-class=true #ASM 的用途:AOP 结合 javaagent 可以实现 热部署,以及日志追踪(类似 SkyWalking )。 这类不影响业务agent模式还是bytebuddy(asm)好点 arthas 的运行也是基于这个 javaagent 和 ASM 的,同时还使用到 JVMTI(JVM Tool Interface) https://www.cnblogs.com/cruze/p/3865180.html https://www.cnblogs.com/cruze/category/593899.html private Object handle(MiniRpcRequest request) throws Throwable { String serviceKey = RpcServiceHelper.buildServiceKey(request.getClassName(), request.getServiceVersion()); Object serviceBean = rpcServiceMap.get(serviceKey); if (serviceBean == null) { throw new RuntimeException(String.format("service not exist: %s:%s", request.getClassName(), request.getMethodName())); } Class<?> serviceClass = serviceBean.getClass(); String methodName = request.getMethodName(); Class<?>[] parameterTypes = request.getParameterTypes(); Object[] parameters = request.getParams(); FastClass fastClass = FastClass.create(serviceClass); // 比enHance更简单直接 int methodIndex = fastClass.getIndex(methodName, parameterTypes); return fastClass.invoke(methodIndex, serviceBean, parameters); }