public JavaFileObject useSource(final JavaFileObject name) {
        JavaFileObject prev = currentSource();
        if (name != prev) {
            source = new JCDiagnostic.DiagnosticSource() {
                    public JavaFileObject getFile() {
                        return name;
                    }
                    public CharSequence getName() {
                        if (name instanceof BaseFileObject)
                            return ((BaseFileObject) name).getShortName();
                        else
                            return BaseFileObject.getSimpleName(name);
                    }
                    public int getLineNumber(int pos) {
                        return Log.this.getLineNumber(pos);
                    }
                    public int getColumnNumber(int pos) {
                        return Log.this.getColumnNumber(pos);
                    }
                    public Map<JCTree, Integer> getEndPosTable() {
                        return (endPosTables == null ? null : endPosTables.get(name));
                    }
                };
            buf = null;
        }
        return prev;
    }