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[]
..
Type をどのように表現し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には何もありませんint[]
。