Wrong Stack Size calculated by ASM library

百般思念 提交于 2019-12-02 06:02:05

You can’t omit the call to visitMax. From the documentation of ClassWriter.COMPUTE_MAXS:

If this flag is set, then the arguments of the visitMaxs method of the MethodVisitor returned by the visitMethod method will be ignored, and computed automatically from the signature and the bytecode of each method.

In other words, when you specify the flag, you may pass in whatever you want, e.g. call visitMax(-1,-1) to emphasize that you are not providing the actual values, but you still have to call the method to trigger the computation of the correct values.

By the way, since you create a class file of version 51 you should specify COMPUTE_FRAMES as I doubt that you want to create StackMapTable attributes manually. Note that COMPUTE_FRAMES implies COMPUTE_MAXS behavior.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!