我正在尝试将自定义行为添加到系统类(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");
}
我看到没有系统类没有传递给转换。
有没有办法修改系统类?提前致谢!