的VerifyError:堆栈尺寸过大(这是什么意思?) [英] VerifyError: Stack size too large (what does it mean?)

查看:386
本文介绍了的VerifyError:堆栈尺寸过大(这是什么意思?)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是相当新的Java字节code。我使用BCEL生成字节code,但是当我尝试使用产生code我得到一个错误信息。 (回想起来,这看起来就像是ObjectWeb ASM更先进,更普遍比BCEL使用。)

I'm fairly new to Java bytecode. I'm using BCEL to generate bytecode, but I get an error message when I try to use the generated code. (In hindsight, it looks like ObjectWeb ASM is more advanced and more commonly used than BCEL.)

下面是错误消息:

Exception in thread "main" java.lang.VerifyError: 
(class: cb/io/FileDescriptor, method: set 
 signature: (I)J) 
Stack size too large

下面是方法:

// Method descriptor #4 (I)J
// Stack: 0, Locals: 1
private static long set(int arg1);
  0  lconst_0
  1  lreturn
    Local variable table:
      [pc: 0, pc: 2] local: arg1 index: 0 type: int

据我所知,局部变量表是正确的,因为它的输入参数匹配。我还没有添加一个这个变量,因为该方法是静态的。

From what I understand, the local variable table is correct because it matches the input parameter. I haven't added a 'this' variable because the method is static.

如果我没有记错,lconst_0加载的0长值压入堆栈,并lreturn消耗的值,并返回它。

If I'm not mistaken, lconst_0 loads a long value of 0 onto the stack, and lreturn consumes that value and returns it.

我是什么做错了吗?这里是否有足够的信息来告诉?

What am I doing wrong? Is there enough information here to tell?

谢谢!

推荐答案

您必须声明你用每一个Java方法的最大堆栈大小。 ASM比如可以自动计算出的值,这样可以节省很多的麻烦。最大堆栈大小为插槽您在方法中使用的绝对最大金额(一次,不累计)。做分支时,计算可能会非常棘手。

Your have to declare the maximum stack size you use for every Java method. ASM for example can calculate the values automatically, which saves you a lot of trouble. The maximum stack size is the absolute maximum amount of slots you use in the method (at once, not accumulated). The calculations can get very tricky when doing branching.

您在这儿加载值,取值消耗2栈槽(其实,每64个位值(除指针)消耗2堆栈槽),所以你必须在这里设置2的最大堆栈大小。

You're loading a long value here, longs consume 2 stack slots (in fact, every 64 bit value (except pointers) consume 2 stack slots), so you have to set a maximum stack size of 2 here.

堆栈尺寸过大只是告诉你,如方法描述中指定的方法消耗更多的栈槽。

The Stack size too large just tells you that your method consumes more stack slots as are specified in the method descriptor.

这篇关于的VerifyError:堆栈尺寸过大(这是什么意思?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆