Monday, September 27, 2010

Difference in comparin Integer between JDK 1.6.0_11 and JDK 1.6.0_18

Quite busy summer, but just to post quick info about thing that happened to me a moment ago.

I develop application on a Windows machine, test it etc. and once a day I deploy it to our Linux server for our testers. You know those situations "App works perfectly on my machine, but crashes in production"? Well, after checking parameters and other config stuff, I turned myself to my Log4j trace (yeah, should have done that first) and it turned out that certain validation of mine fails.
It compares two Integer values, in this example 37 and 37, by using != operator.

So, machine A, JDK 1.6.0_18, a == b returns true
Machine B, JDK 1.6.0_11 a==b returns false.

where a and b are Integer(37).

Safe way, of course, is using equals method, or comparing by intValue property.

A lot of interesting stuff about RichFaces in my project has happened this summer, but I leave that for some other time. Deadlines and stuff, you know :)

No comments:

Post a Comment