Search code examples
mvel

Reason for Exception java.lang.VerifyError: Bad type on operand stack while writing rule in Mvel


I am newbie to Mvel. I am getting a error while executing following mvel expression. This expression executes well for plans which are under size 20 but not greater than that.This behaviour is shown by plans which have size more than 20.

if (true) { tmp.__tmp = ent.data.plans; if (tmp.__tmp != null) { for (int index =0; index < ent.data.plans.size(); index++){ element=ent.data.plans[index]; System.out.println(element.name );}}}

getting error below

java.lang.VerifyError: Bad type on operand stack Exception Details: Location: ASMAccessorImpl_4263943071452801154960.getValue(Ljava/lang/Object;Ljava/lang/Object;Lorg/mvel2/integration/VariableResolverFactory;)Ljava/lang/Object; @45: invokeinterface Reason: Type 'java/lang/Object' (current frame, stack[1]) is not assignable to integer Current Frame: bci: @45 flags: { } locals: { 'ASMAccessorImpl_4263943071452801154960', 'java/lang/Object', 'java/lang/Object', 'org/mvel2/integration/VariableResolverFactory' } stack: { 'java/util/List', 'java/lang/Object' } Bytecode: 0x0000000: 2d12 0eb9 0014 0200 b900 1901 00c0 001b 0x0000010: 121d b900 2102 00c0 0023 b600 27c0 0029 0x0000020: 2d12 2bb9 0014 0200 b900 1901 00b9 002e 0x0000030: 0200 b0

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.newInstance(Class.java:412)

Please help.


Solution

  • I was getting an exception caused by org.mvel2.optimizers.OptimizationNotSupported .This behavior was shown as DynamicOptimizer doesn't have any fallback when ASM optimizer fails. Reflective optimizers seems to be the good fallback option there and mvel fixed this is the latest version of mvel2 (2.2.7).

    I have upgraded mvel2 version and now null-safe bean navigation are working fine.