我正在尝试为系统类(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");
}
我看到没有传递系统类来进行转换。
有没有办法修改系统类呢?提前感谢!