我如何在 BCEL 检查这个..
说java中的字节码是
newarray 10 (int)
我已经为访客完成了
instruction instanceof NEWARRAY
public boolean visit(Instruction instr) {
return instr instanceof NEWARRAY;
}
但我还必须检查 newarray 是否是int[]
我如何在 BCEL 中检查这个?
我试过这个
&& ((NEWARRAY) instr).getType() == Type.INT;
好
return instr instanceof NEWARRAY && ((NEWARRAY) instr).getType() == Type.INT;
但是你可以看到上面的 ^ 不会起作用,因为它永远不会int
......但是int[]
但Type.INT
只是int
..而不是int[]
..
我如何表示类型int[]
?
我正在阅读 BCEL 源代码,NEWARRAY.getType() 返回这个..
/**
* @return type of constructed array
*/
public final Type getType() {
return new ArrayType(BasicType.getType(type), 1);
}
如您所见,它返回一个Type
类,所以..查看
http://commons.apache.org/bcel/apidocs/org/apache/bcel/generic/Type.html
http://commons.apache.org/bcel/apidocs/org/apache/bcel/generic/ArrayType.html
Type
ARRAY没有任何's int[]
。