关于放射的数组类型Value
class boy{
}
class temp{
boy[] a;
int b;
}
类temp的反射,,,它一个对象的引用ObjectReference or 传到函数build中去,想在那里根据它把这个对象还原出来(新建一个一模一样的)
,,,,,,,
,,,,,,,
private void build(temp G,ObjectReference or){
Field v_a = or.referenceType().fieldByName("a");
Field v_b = or.referenceType().fieldByName("b"); //还原Int型比较容易我可以解决,主要是数组类型,总是有问题
Object[] j1 = null;
Value vex = or.getValue(v_a);
ArrayReference ar = (ArrayReference)vex;
List<Value> L1 =ar.getValues();
j1 = L1.toArray();
for(int i = 0; i < j1.length; i++)
G.a[i] = (boy)j1[i]; //此处意图将Object类转化为temp类
}
编译无错,但是,在运行出错,显示说
java.lang.ClassCastException: com.sun.tools.jdi.ObjectReferenceImpl cannot be cast to com.blue.jsw.boy
出错行就是上面又注释的那最后一行,,为什么说(boy)j1[i] 是ObjectReferenceImpl类型,这是什么类型