Java数据类型不匹配异常处理,java.lang.VerifyError:堆栈映射与异常处理程序中的不匹配...

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

try{

-----

} catch (NumberFormatException|CalculationException e) {

}

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.

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) 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) Another workaround is by using the parent exception: RuntimeException in catch block instead of combining two exception.

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])

解决方案

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

-XX:-UseSplitVerifier

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值