java.lang.VerifyError:堆栈映射与异常处理程序中的不匹配 [英] java.lang.VerifyError: Stack map does not match the one at exception handler

查看:1511
本文介绍了java.lang.VerifyError:堆栈映射与异常处理程序中的不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在JVM加载字节码期间,此java.lang.VerifyError带有如下代码段。

Faced this java.lang.VerifyError with code snippet as below during JVM loading bytecode.

try{
-----
}  catch (NumberFormatException|CalculationException e) {

}

此处CalculationException是自定义异常,它扩展了java.lang.RuntimeException,而NumberFormatException是标准Java RuntimeException。
在代码编译并在本地Windows机器上运行良好的情况下。

Here CalculationException is custom exception which extends java.lang.RuntimeException, while NumberFormatException is standard Java RuntimeException. While the code compile and run fine locally windows machine.

在QA / prod / Dev Unix节点之一上失败并显示VerifyError,并且在其他unix节点。虽然两个Unix节点具有相同的配置(使用RedHat 6.2和1.8 jdk以及相同版本的jar文件),但也比较了javap -c在两个节点上生成的字节码,并发现相同。

It fails with VerifyError on one of the QA/prod/Dev unix node, and works fine on other unix node. While both unix nodes have the same config (using RedHat 6.2 and 1.8 jdk and same version jar files) also compared the bytecode generated on both nodes by javap -c and found this same.

我在错误的节点上也找到了两种方法来解决此问题。

I found two ways to resolve this on erroneous node also.

1)由于此错误来自字节码验证步骤,请尝试通过禁用字节码验证来解决在dev unix上显示为-Xverify:none(也尝试过-XX:-UseSplitVerifier但效果不错,因为我认为它已从jdk 8禁用)
但是我们不会在prod中禁用字节码验证,因此一直在寻找一些方法其他解决方法。

1) As this error is coming at byte-code verification step, tried by disabling the bytecode verification on dev unix box as -Xverify:none (Also tried -XX:-UseSplitVerifier but dint work, as i think its disabled from jdk 8) However as we shall not disable bytecode verification in prod, have been looking for some other workaround.

2)另一个解决方法是使用父异常:catch块中的RuntimeException而不是合并两个异常。

2) Another workaround is by using the parent exception: RuntimeException in catch block instead of combining two exception.

如果Java确实存在这种捕获方式的问题,为什么我不能理解,为什么编译器dint抱怨它,为什么它可以在一台机器上运行而不能在其他具有相同配置的机器上运行。
错误原因也没有意义,它说:不能将CalculationException(当前帧,stack [0])分配给'java / lang / RuntimeException
,而实际上它是由

What I am not able to understand if Java does have issue with this way of catching, why compiler dint complained it and why it works on one machine and not on other which have same config. Also the error reason is not making sense which says: CalculationException (current frame, stack[0]) is not assignable to 'java/lang/RuntimeException While its actually assignable as tested by

if (RuntimeException.class.isAssignableFrom(CalculationException.class)){
    System.out.println("Assisgnable");
}

完全例外详细信息:
位置:

Full Exception Details: Location:

    com/markit/valuations/marketdata/snapper/domain/credit/BeanWrapperBuilder_CDXOCompositeVolSurface.getSpreadVol(Lcom/markit/valuations/dates/ImmutableDate;Lcom/markit/valuations/marketdata/data/indexeddata/IndexedData;DLcom/markit/valuations/dates/ImmutableDate;Lcom/markit/valuations/dates/ImmutableDate;Ljava/lang/String;Ljava/lang/String;Lcom/markit/qag/analytics/credit/indexpv/swaption/CreditIndexSwaptionCalculator;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/Double; @51: astore
  Reason:
    Type 'com/markit/valuations/common/CalculationException' (current frame, stack[0]) is not assignable to 'java/lang/RuntimeException' (stack map, stack[0])
  Current Frame:
    bci: @0
    flags: { }
    locals: { 'com/markit/valuations/marketdata/snapper/domain/credit/BeanWrapperBuilder_CDXOCompositeVolSurface', 'com/markit/valuations/dates/ImmutableDate', 'com/markit/valuations/marketdata/data/indexeddata/IndexedData', double, double_2nd, 'com/markit/valuations/dates/ImmutableDate', 'com/markit/valuations/dates/ImmutableDate', 'java/lang/String', 'java/lang/String', 'com/markit/qag/analytics/credit/indexpv/swaption/CreditIndexSwaptionCalculator', 'java/lang/String', 'java/lang/String' }
    stack: { 'com/markit/valuations/common/CalculationException' }
  Stackmap Frame:
    bci: @51
    flags: { }
    locals: { 'com/markit/valuations/marketdata/snapper/domain/credit/BeanWrapperBuilder_CDXOCompositeVolSurface', 'com/markit/valuations/dates/ImmutableDate', 'com/markit/valuations/marketdata/data/indexeddata/IndexedData', double, double_2nd, 'com/markit/valuations/dates/ImmutableDate', 'com/markit/valuations/dates/ImmutableDate', 'java/lang/String', 'java/lang/String', 'com/markit/qag/analytics/credit/indexpv/swaption/CreditIndexSwaptionCalculator', 'java/lang/String', 'java/lang/String' }
    stack: { 'java/lang/RuntimeException' }
  Bytecode:
    0x0000000: 2c19 0ab9 0015 0200 b800 cb2b 1906 ba00
    0x0000010: cc00 00b6 00cd ba00 ce00 00b6 00cf 1909
    0x0000020: ba00 d000 00b6 00cf 0eb8 003b b600 d1c0
    0x0000030: 0091 b03a 0cbb 0048 59b7 0049 12d3 b600
    0x0000040: 4b19 0ab6 004b 12d4 b600 4b2c 1254 b900
    0x0000050: 1502 00b6 004b 12d5 b600 4b29 b600 4c12
    0x0000060: d6b6 004b 1907 b600 4b12 d7b6 004b 1905
    0x0000070: b600 5b12 d8b6 004b 1906 b600 5b12 d9b6
    0x0000080: 004b 190b b600 4b12 dab6 004b 1908 b600
    0x0000090: 4bb6 004d 3a0d b200 4719 0d19 0cb9 0081
    0x00000a0: 0300 0eb8 003b b0
  Exception Handler Table:
    bci [0, 50] => handler: 51
    bci [0, 50] => handler: 51
  Stackmap Table:
  same_locals_1_stack_item_frame(@51,Object[#535])


推荐答案

您需要在配置中设置以下jvm参数:

you need to set the following jvm args in your config:

-XX:-UseSplitVerifier

-XX:-UseSplitVerifier

这篇关于java.lang.VerifyError:堆栈映射与异常处理程序中的不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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