IG: two bugs a week. Does that deserve an inspection?

I've hit very same problem twice this week:

String s = "Hello " + foo;

where foo is of class Hoo, which doesn't redefine toString() from java.lang.Object.


Wouldn't that be a good candidate for 'Probable bugs' IG category?

-


Maxim Shafirov
http://www.jetbrains.com
"Develop with pleasure!"


4 comments
Comment actions Permalink


Yup, that's a good one, and one I've hit myself. Object.toString() is essentially never what you want, and it's easy to make it happen unexpectedly with a concatenation. I'll filter for enumerated classes (which get a goot toString() automatically), and I'll have to punt for interfaces (since I won't know if the implementation has a toString()). Should be pretty easy.

--Dave Griffith

0
Comment actions Permalink

Good idea. Stumbled over that one too, ooccasionally.

Maxim Shafirov (JetBrains) wrote:

I've hit very same problem twice this week:

String s = "Hello " + foo;

where foo is of class Hoo, which doesn't redefine toString() from
java.lang.Object.


Wouldn't that be a good candidate for 'Probable bugs' IG category?

-------------------
Maxim Shafirov
http://www.jetbrains.com
"Develop with pleasure!"

0
Comment actions Permalink

Done.

--Dave Griffith

0
Comment actions Permalink

Cool! Thanks
-


Maxim Shafirov
http://www.jetbrains.com
"Develop with pleasure!"


0

Please sign in to leave a comment.