4

Findbugs は、以下のステートメントで NP_NULL_PARAM_DEREF_NONVIRTUAL をトリガーします

findbugs が registerationdate を非 null パラメータとして認識する理由がわかりません。2 番目のコンストラクターが登録日付の null 値をチェックしていることがわかります。したがって、null deref の可能性はありません。

このバグは誤検知ですか、それとも findbugs にはパラメーターの非 null をチェックする別のメカニズムがありますか?

前もって感謝します、ザーラ

Participant seppl = new Participant( "Mayer", "Seppel", null);

Participant has two constructors:
public Participant() {      
    surname = "";
    forename = "";      
    registrationDate = new Date();      
}

public Participant (String surname, String forename, Date registrationDate) {

    setSurname(surname);
    setForename(forename);      
    setRegistrationDate(registrationDate);      
 }

 public void setRegistrationDate (Date registrationDate) {
    if (registrationDate != null
            && !registrationDate.equals(this.registrationDate)) {
        this.registrationDate = registrationDate;           

    }
    }
4

1 に答える 1

1

ありがとうそれは私のせいでした...「registrationDate != null」を追加すると、バグは消えました..

于 2014-07-26T08:25:29.680 に答える