如何在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
没有任何用于数组int[]的Type。
发布于 2011-08-16 12:52:04
我想我不能很好地理解你的问题,但是这个怎么样:
if(instr.getClass().isArray()) return instr instanceof NEWARRAY[];
else return instr instanceof NEWARRAY;https://stackoverflow.com/questions/7073622
复制相似问题