logo       

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

java.findbugs.general

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

I'm not complaining about the idiom, I'm commenting on the subtleties of getting
a static analysis engine to understand the idiom. Yes, this is a better way of handling it
than the one that checks against a specific type if the equals method will be inherited in
subclasses.

Bill


On Dec 5, 2006, at 9:09 AM, Nils Kilden-Pedersen wrote:

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.


_______________________________________________
Findbugs-discuss mailing list
Findbugs-discuss@xxxxxxxxxxxxxxxxxx
http://mailman.cs.umd.edu/mailman/listinfo/findbugs-discuss



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

News | FAQ | advertise