logo       

Re: Re: BC: Unchecked/unconfirmed cast (BC_UNCONFIRMED_CAST): msg#00018

java.findbugs.general

Subject: Re: Re: BC: Unchecked/unconfirmed cast (BC_UNCONFIRMED_CAST)

An example where this idiom:

public boolean equals(Object object) {
    if (this.getClass() == object.getClass() {
        MyClass that = (MyClass) object;
        ...
    }
    ...
}

is correct and valid, is as an (abstract) super implementation, where sub classes only extend behavior, not data. The super class provides an equality method, which tests equality on common data, but only if the instances are of the exact same class.
For this example, MyClass.class == o.getClass() won't work.




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise