有没有办法让这个由字节伙伴生成的类文件包含本地变量表?



我正在使用字节伙伴自动打印方法日志,但我发现如果我使用字节伙伴来重新生成类文件,LocalVariableTable 将被覆盖并消失.这将使 springmvc 不起作用,因为 springmvc 使用 LocalVariableTable 来获取方法参数的名称,如果没有 LocalVariableTable,程序会去 wrong.so 字节好友如何使用 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));

如果使用拦截,则定义一个新方法,并将旧方法备份到另一个位置以便能够调用它。这包括存储此信息的调试表。但是,您可以使用-parameters参数编译类。这些更官方的信息由Byte Buddy保留。

最新更新