4

最近 WSED 5.2 から RAD 7.5 に移行した時点で、アプリケーションを破壊するバグがコードに現れました。

RAD 7.5 は、すべてクラス ヘッダーの宣言でそれをマークします ( public class FoStringWriter extends StringWriter implements FoWriter {)

- Exception IOException in throws clause of Writer.append(CharSequence, int, int) is not compatable with StringWriter.append(CharSequence, int, int)
- Exception IOException in throws clause of Writer.append(char) is not compatable with StringWriter.append(char)
- Exception IOException in throws clause of Writer.append(CharSequence) is not compatable with StringWriter.append(CharSequence)

私がウェブ上で見つけたすべての文献は、これが Eclipse の「バグ」であることを示していますが、私の開発者はすでに最新バージョンの Eclipse ソフトウェアをインストールしているはずです。したがって、このエラーをどうすればよいかわからないままです。まだ更新していない IBM からの修正プログラムはありますか? または、このエラーを修正できるコード修正はありますか?

public class FoStringWriter extends StringWriter implements FoWriter {

public void filteredWrite(String str) throws IOException {
FoStringWriter.filteredWrite(str,this);
}

public static void filteredWrite(String str, StringWriter writer) throws IOException {
    if (str == null) str = "";
    TagUtils tagUtils = TagUtils.getInstance();
    str = tagUtils.filter(str);
    HashMap dictionary = new HashMap();
    dictionary.put("&#","&#");
    str = GeneralUtils.translate(str,dictionary);
    writer.write(str);      
}

}

編集者注:

これが実行するプロセスにより、アプリ用の PDF ドキュメントが作成されます。WSED 5.5 では、動作し、いくつかのエラーがありましたが、PDF の書き込みを止めるものは何もありませんでした。

4

1 に答える 1

1

これは、一見完全に明白な答えによって解決される別の「エラー」であるため、額を叩いてください。

リストされた「エラー」をスローするメソッドを追加するだけで、このクラスを呼び出すときにスローされるエラーを排除できます。

それらを StringWriter から直接コピーすると、実際には編集せずに機能しました。

public StringWriter append(char c) {
    write(c);
    return this;
}

public StringWriter append(CharSequence csq) {
    if (csq == null)
        write("null");
    else
        write(csq.toString());
        return this;
}

public StringWriter append(CharSequence csq, int start, int end) {
    CharSequence cs = (csq == null ? "null" : csq);
    write(cs.subSequence(start, end).toString());
        return this;
}

私はこれが機能したことに満足していると同時に、あまりにも単純な修正であり、理解するのに丸 1 週間近くかかったことに不満を感じています。

このエラーの背後にある理由は、実装の競合である可能性が高いと思います。FoStringWriter は StringWriter を拡張しますが、それ自体は Writer を拡張し、両方のクラスには互いに上書きする独自の「追加」メソッドがあります。それらを明示的に作成することで、このエラーは解決されます。

于 2013-11-20T19:05:57.193 に答える