java.lang.verify错误:堆栈高度1不一致!=2.

java.lang.verify错误:堆栈高度1不一致!=2.,java,bytecode,instruction-set,bytecode-manipulation,javap,Java,Bytecode,Instruction Set,Bytecode Manipulation,Javap,我有一个自定义应用程序,其中我们生成了Java指令代码。我们使用javacc生成代码。在其中一个场景中,我们得到java.lang.verify错误:堆栈高度不一致1!=2 我检查了生成的类文件,并尝试解码指令集,但无法理解为什么会出现此错误。 类:测试,方法:runFunc签名:()Ljava/lang/Object;)堆栈高度不一致1!=2 详细的例外情况如下: *java.lang.VerifyError:(类:Test,方法:runFunc签名:()Ljava/lang/Object;)

我有一个自定义应用程序,其中我们生成了Java指令代码。我们使用javacc生成代码。在其中一个场景中,我们得到java.lang.verify错误:堆栈高度不一致1!=2

我检查了生成的类文件,并尝试解码指令集,但无法理解为什么会出现此错误。 类:测试,方法:runFunc签名:()Ljava/lang/Object;)堆栈高度不一致1!=2

详细的例外情况如下:

*java.lang.VerifyError:(类:Test,方法:runFunc签名:()Ljava/lang/Object;)堆栈高度不一致1!=二,

at java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671)
    at java.lang.Class.getConstructor0(Class.java:3075)
    at java.lang.Class.getDeclaredConstructor(Class.java:2178)
我检查了生成的类代码,runFunc函数如下所示:

protected final Object runFunc() {
        out = ((myPage) this).pageContext.getOut();
        parent = ((myPage) this).parent;
        ((myPage) this).pageContext.setPageEncoding("test");

        this.__tempIntertnalARRYSTRUCTVAR0.set(currentPage.StructNew());
        __myapp_internal_sdref_ = Cast._Map(_autoscalarize(this.__tempIntertnalARRYSTRUCTVAR0));
        __myapp_internal_sdref___restkeys = new ArrayList(4);
        _setDref_Struct(null, __myapp_internal_sdref_, "a", false);
        _set("rest", myPage._dreference_map_rest(__myapp_internal_sdref_, __myapp_internal_sdref___restkeys));

        outVar = (printOutput) _initFunction(class$myApplication$ext$io$printOutput, 0, parent);
        _setCurrentLineNo(41);
        outVar.hasEndAttribute(true);

        try {
            if ((mode0 = outVar.doStart()) != 0)
                do {

                } while (outVar.doAfterBody() != 0);
            if (outVar.doEnd() == 5) {
                t8 = null;
                outVar.doFinally();
                return t8;
            }
            outVar.doFinally();
        } catch (Throwable throwable) {
            outVar.doCatch(throwable);
            outVar.doFinally();
        } catch (Throwable throwable) {
            outVar.doFinally();
            throw throwable;
        }
        _whitespace((Writer) out, "\r\n\r\n\r\n\r\n");
        return null;
    }
而使用javap实用程序获得的相同函数的生成指令代码如下所示:

protected final java.lang.Object runFunc();
    Code:
    0:aload_0
    1:getfield      #40                 // Field myApplication/runtime/myPage.pageContext:LmyApplication/runtime/AppPageContext;
    4:invokevirtual #46                 // Method javax/servlet/jsp/JspContext.getOut:()Ljavax/servlet/jsp/JspWriter;
    7:astore_1
    8:aload_0
    9:getfield      #50                 // Field myApplication/runtime/myPage.parent:Ljavax/servlet/jsp/ext/Operation;
    12:astore_3
    13:aload_0
    14:getfield      #40                 // Field myApplication/runtime/myPage.pageContext:LmyApplication/runtime/AppPageContext;
    17:ldc           #52                 // String test
    19:invokevirtual #58                 // Method myApplication/runtime/AppPageContext.setPageEncoding:(Ljava/lang/String;)V
    22:aload_0
    23:getfield      #33                 // Field __tempIntertnalARRYSTRUCTVAR0:LmyApplication/runtime/Variable;
    26:invokestatic  #62                 // Method myApplication/runtime/currentPage.StructNew:()Ljava/util/Map;
    29:invokevirtual #68                 // Method myApplication/runtime/Variable.set:(Ljava/lang/Object;)V
    32:aload_0
    33:aload_0
    34:getfield      #33                 // Field __tempIntertnalARRYSTRUCTVAR0:LmyApplication/runtime/Variable;
    37:invokevirtual #72                 // Method myApplication/runtime/myPage._autoscalarize:(myApplication/runtime/Variable;)Ljava/lang/Object;
    40:invokestatic  #78                 // Method myApplication/runtime/Cast._Map:(Ljava/lang/Object;)Ljava/util/Map;
    43:astore 4
    45:new           #80                 // class java/util/ArrayList
    48:dup
    49:iconst_4
    50:invokespecial #83                 // Method java/util/ArrayList."<init>":(I)V
    53:astore 5
    55:aload_0
    56:aconst_null
    57:aload 4
    59:ldc           #85                 // String a
    61:iconst_0
    62:invokevirtual #89                 // Method myApplication/runtime/myPage._setDref_Struct:(Ljava/lang/String;Ljava/util/Map;Ljava/lang/Object;Z)V
    65:aload 5
    67:ldc           #85                 // String a
    69:invokeinterface #95,2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
    74:aload_0
    75:ldc           #97                 // String rest
    77:aload 4
    79:aload 5
    81:invokestatic  #101                // Method myApplication/runtime/myPage._dreference_map_rest:(Ljava/util/Map;Ljava/util/List;)Ljava/util/Map;
    84:invokevirtual #105                // Method myApplication/runtime/myPage._set:(Ljava/lang/String;Ljava/lang/Object;)V
    87:aload_0
    88:getstatic     #117                // Field class$myApplication$ext$io$printOutput:Ljava/lang/Class;
    91:iconst_0
    92:aload_3
    93:invokevirtual #121                // Method myApplication/runtime/myPage._initFunction:(Ljava/lang/Class;ILjavax/servlet/jsp/ext/Operation;)Ljavax/servlet/jsp/ext/Operation;
    96:checkcast     #123                // class myApplication/ext/io/printOutput
    99:astore 6
    101:aload_0
    102:bipush 41
    104:invokevirtual #126                // Method myApplication/runtime/myPage._setCurrentLineNo:(I)V
    107:aload 6
    109:iconst_1
    110:invokevirtual #132                // Method myApplication/ext/GenericOperation.hasEndAttribute:(Z)V
    113:aload 6
    115:invokevirtual #136                // Method myApplication/ext/io/printOutput.doStart:()I
    118:dup
    119:istore 7
    121:ifeq 132
    124:aload 6
    126:invokevirtual #139                // Method myApplication/ext/io/printOutput.doAfterBody:()I
    129:ifne 124
    132:aload 6
    134:invokevirtual #144                // Method myApplication/ext/QueryLoop.doEnd:()I
    137:iconst_5
    138:if_icmpne 150
    141:aconst_null
    142:astore 8
    144:jsr 179
    147:aload 8
    149:areturn
    150:jsr 179
    153:goto 188
    156:astore 9
    158:aload 6
    160:aload 9
    162:invokevirtual #148                // Method myApplication/ext/QueryLoop.doCatch:(Ljava/lang/Throwable;)V
    165:jsr 179
    168:goto 188
    171:astore 10
    173:jsr 179
    176:aload 10
    178:athrow
    179:astore 11
    181:aload 6
    183:invokevirtual #151                // Method myApplication/ext/io/printOutput.doFinally:()V
    186:ret 11
    188:aload_0
    189:aload_1
    190:ldc           #153                // String \r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n
    192:invokevirtual #157                // Method myApplication/runtime/myPage._whitespace:(Ljava/io/Writer;Ljava/lang/String;)V
    195:aconst_null
    196:areturn
protectedfinal java.lang.Object runFunc();
代码:
0:aload_0
1:getfield#40//Field myApplication/runtime/myPage.pageContext:lmyaapplication/runtime/AppPageContext;
4:invokevirtual#46//Method javax/servlet/jsp/JspContext.getOut:()Ljavax/servlet/jsp/JspWriter;
7:astore_1
8:aload_0
9:getfield#50//Field myApplication/runtime/myPage.parent:Ljavax/servlet/jsp/ext/Operation;
12:astore_3
13:aload_0
14:getfield#40//Field myApplication/runtime/myPage.pageContext:lmyaapplication/runtime/AppPageContext;
17:ldc#52//字符串测试
19:invokevirtual#58//方法myApplication/runtime/AppPageContext.setPageEncoding:(Ljava/lang/String;)V
22:aload_0
23:getfield#33//Field uu tempInternalarryStructVar0:LMYAApplication/runtime/Variable;
26:invokestatic#62//方法myApplication/runtime/currentPage.StructNew:()Ljava/util/Map;
29:invokevirtual#68//方法myApplication/runtime/Variable.set:(Ljava/lang/Object;)V
32:aload_0
33:aload_0
34:getfield#33//Field uu tempInternalarryStructVar0:lmyaApplication/runtime/Variable;
37:invokevirtual#72//方法myApplication/runtime/myPage._自动缩放:(myApplication/runtime/Variable;)Ljava/lang/Object;
40:invokestatic#78//方法myApplication/runtime/Cast._Map:(Ljava/lang/Object;)Ljava/util/Map;
43:astore 4
45:new#80//class java/util/ArrayList
48:dup
49:iconst_4
50:invokespecial#83//方法java/util/ArrayList.“:(I)V
53:astore 5
55:aload_0
56:aconst_null
57:aload 4
59:ldc#85//字符串a
61:iconst_0
62:invokevirtual#89//Method myApplication/runtime/myPage._setDref_Struct:(Ljava/lang/String;Ljava/util/Map;Ljava/lang/Object;Z)V
65:aload 5
67:ldc#85//字符串a
69:invokeinterface#95,2//InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
74:aload_0
75:ldc#97//String rest
77:aload 4
79:aload 5
81:invokestatic#101//Method myApplication/runtime/myPage.(参考图)rest:(Ljava/util/map;Ljava/util/List;)Ljava/util/map;
84:invokevirtual#105//方法myApplication/runtime/myPage._set:(Ljava/lang/String;Ljava/lang/Object;)V
87:aload_0
88:getstatic#117//fieldclass$myApplication$ext$io$printOutput:Ljava/lang/class;
91:iconst_0
92:aload_3
93:invokevirtual#121//Method myApplication/runtime/myPage._initFunction:(Ljava/lang/Class;ILjavax/servlet/jsp/ext/Operation;)Ljavax/servlet/jsp/ext/Operation;
96:checkcast#123//class myApplication/ext/io/printOutput
99:astore 6
101:aload_0
102:bipush 41
104:invokevirtual#126//方法myApplication/runtime/myPage._setCurrentLineNo:(I)V
107:aload 6
109:iconst_1
110:invokevirtual#132//方法myApplication/ext/genericooperation.hasEndAttribute:(Z)V
113:aload 6
115:invokevirtual#136//方法myApplication/ext/io/printOutput.doStart:()I
118:dup
119:史前7
121:ifeq 132
124:aload 6
126:invokevirtual#139//方法myApplication/ext/io/printOutput.doAfterBody:()I
129:ifne 124
132:aload 6
134:invokevirtual#144//方法myApplication/ext/querylop.doEnd:()I
137:iconst_5
138:if_icmpne 150
141:aconst_null
142:astore 8
144:jsr 179
147:aload 8
149:轮到你了
150:jsr 179
153:转到188
156:astore 9
158:aload 6
160:aload 9
162:invokevirtual#148//方法myApplication/ext/querylop.doCatch:(Ljava/lang/Throwable;)V
165:jsr 179
168:转到188
171:astore 10
173:jsr 179
176:aload 10
178:athrow
179:astore 11
181:aload 6
183:invokevirtual#151//方法myApplication/ext/io/printOutput.doFinally:()V
186:ret 11
188:aload_0
189:aload_1
190:ldc#153//String\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n
192:invokevirtual#157//方法myApplication/runtime/myPage._空格:(Ljava/io/Writer;Ljava/lang/String;)V
195:aconst_空
196:轮到你了
如果有人能告诉我堆栈im平衡发生在哪里,我将不胜感激? 期待着积极的回应,
提前感谢。

试试新的JDK。他们可能会在异常消息中提供更多信息。感谢@Holger的响应,我尝试使用Java15,错误保持不变。异常如下所示:java.lang.VerifyError:(类:Test,方法:runFunc签名:()Ljava/lang/Object;)堆栈高度不一致1!=2.