System.out.println() 呼び出しをすべてのメソッドの最初の行 (init および clinit メソッドを除く) に追加して、どのメソッドがいつ呼び出されるかを確認するために BCEL を使用しています。
これは私のコードatmです(いくつかの擬似を含む):
Instruction ins = null;
f (first instruction is ALOAD_0) {
ins = get next instruction
} else {
ins = this instruction;
}
list.insert(ins, new GETSTATIC(cgen.getConstantPool().addFieldref("java/lang/System", "out", "Ljava/io/PrintStream;")));
list.insert(ins, new LDC(cgen.getConstantPool().addUtf8("debug message")));
list.insert(ins, new INVOKEVIRTUAL(cgen.getConstantPool().addMethodref("java/io/PrintStream", "println", "(Ljava/lang/String;)V")));
編集されたクラスはバイトコードでは問題ないように見えますが、何らかの理由でこのクラスは機能しません。私が間違っていることはありますか?