@Override public JavaFileObject getJavaFileForOutput(Location location, String className, javax.tools.JavaFileObject.Kind kind, final FileObject sibling) throws IOException { JavaFileObject fileObject = super.getJavaFileForOutput(location, className, kind, sibling); return new ForwardingJavaFileObject<JavaFileObject>(fileObject) { @Override public OutputStream openOutputStream() throws IOException { record(sibling != null ? FileObjects.toFile(sibling) : null, FileObjects.toFile(fileObject)); return new IncrementalFileOutputStream(FileObjects.toFile(this)); } @Override public Writer openWriter() throws IOException { return encoding != null ? new OutputStreamWriter(openOutputStream(), encoding) : new OutputStreamWriter(openOutputStream()); } }; }