有什么办法可以让字节跳动生成的类文件包含LocalVariableTable?

问题描述 投票:0回答:1

我正在使用byte buddy自动打印方法日志,但是我发现如果我使用byte buddy再生类文件,LocalVariableTable会被覆盖并消失,这将使springmvc无法运行,因为springmvc使用LocalVariableTable来获取方法的args名称,如果没有LocalVariableTable,程序将出错。 我是这样使用的。

DynamicType.Builder<?>.method((isPublic()
                       .and(not(isEquals()))
                       .and(not(isClone()))
                       .and(not(isToString()))
                       .and(not(isHashCode()))
                       .and(not(isDefaultMethod()))
                       .and(not(isDefaultConstructor()))
                       .and(not(isDefaultFinalizer()))
                       .and(not(isAbstract()))
                       .and(not(isStatic()))
                       .and(not(isSetter().or(isGetter()))))
                               .or(isAnnotatedWith(Hook.class)))
                       .intercept(Advice.to(MethodHooks.class));
byte-buddy
1个回答
0
投票

如果你使用拦截,你是在定义一个新的方法,旧的方法被备份到另一个位置,以便能够调用它。这包括存储这些信息的调试表。然而你可以编译一个类 使用 -parameters 参数. 这个比较官方的信息由Byte Buddy保留。

© www.soinside.com 2019 - 2024. All rights reserved.