[英]MVEL expression : java.lang.ClassCastException: [B cannot be cast to java.lang.Object
I am writing few MVEL expression "$input.get('RESULT').array()[1]"
where $input.get('RESULT')
return a ByteBuffer
, so I am converting it into array using array()
and then trying to get value of index 1. where array have 16 attribute. 我正在写一些MVEL表达式
"$input.get('RESULT').array()[1]"
,其中$input.get('RESULT')
返回ByteBuffer
,所以我使用array()
将其转换为array然后尝试获取索引1的值。其中数组具有16个属性。
But when Mvel executing this expression I am getting 但是当Mvel执行这个表达式时
java.lang.ClassCastException: [B cannot be cast to java.lang.Object
I am using below code 我正在使用下面的代码
MVEL.executeExpression(statement, fieldContext.getContext(), fieldContext.getVariables());
I have written other expression as well which is working fine, I am getting this error for Byte one. 我还写了其他表达式,也可以正常工作,我在字节1中遇到此错误。
Any help here will be appreciated. 在这里的任何帮助将不胜感激。
Update : When I use ByteBuffer
get method I got below error so I thought to give a try with array
. 更新:当我使用
ByteBuffer
get方法时,出现以下错误,因此我想尝试一下array
。
java.lang.IllegalAccessError: tried to access class java.nio.HeapByteBuffer from class ASMAccessorImpl_2330495751530608772190
at ASMAccessorImpl_2330495751530608772190.getValue(Unknown Source)
at org.mvel2.optimizers.dynamic.DynamicGetAccessor.getValue(DynamicGetAccessor.java:79)
at org.mvel2.ast.ASTNode.getReducedValueAccelerated(ASTNode.java:108)
at org.mvel2.MVELRuntime.execute(MVELRuntime.java:86)
at org.mvel2.compiler.CompiledExpression.getDirectValue(CompiledExpression.java:123)
at org.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:119)
at org.mvel2.MVEL.executeExpression(MVEL.java:922)`
You don't have to convert to byte[]
with array()
, it should be enough to 您不必使用
array()
转换为byte[]
,它应该足以
$input.get('RESULT').get(1)
as per ByteBuffer.get()
method docs: 根据
ByteBuffer.get()
方法文档:
public abstract byte get(int index)
公共抽象字节get(int索引)
Absolute get method.
绝对获取方法。 Reads the byte at the given index.
读取给定索引处的字节。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.