システム クラス (FileInputStream/FileOutputStream) にカスタム動作を追加しようとしています。次の変換メソッドを使用して、カスタム ClassFileTransformer を作成しました。
public byte[] transform(ClassLoader arg0, String arg1, Class arg2, ProtectionDomain arg3, byte[] arg4) throws IllegalClassFormatException {
System.out.println("class name: " + arg1);
return arg4;
}
サンプルプログラムを実行すると:
public static void main(String[] args) throws Exception {
new FileOutputStream("file");
}
システム クラスがトランスフォームに渡されていないことがわかります。
システムクラスを変更する方法はありますか? 前もって感謝します!