Are there any gotchas in JDK 6 which did not exist in earlier versions? I am interested in finding out some surprising changes like the following one in the way Timestamp.valueOf() works.
Timestamp.valueOf(), when provided with a timestamp which contains a date or a month with a single digit. eg. 2009-9-20, 2009-9-3, 2009-12-4 etc., behaves differently in JDK 6 - it throws an IllegalArgumentException saying that the timestamp is not properly formatted. Whereas JDK 5 (and earlier versions) works just fine providing the proper values with '0' prefixed to those single digit numbers.
JDK 6 is just being more strict because the method does expect it's argument to be a String in JDBC timestamp escape format. However, this BREAKS code written in JDK 5.
Code like:
String s = "2009-9-1 00:00:00";
Timestamp t = Timestamp.valueOf(s);
However JDK 6 is fine with hours, minutes, seconds being single digits. I have figured out what's wrong by looking at the source code of Timestamp class in JDK 6. I found an array intDate[] which is initialized to {4,2,2} and the length of each item in the date is checked against this array.
Now why did the time part work fine even when there are single digits in them? Because the code that checks the length against an equivalent array intTime[] is commented out in source.
The Timestamp class in JDK 5 did not have any of these checks and work just fine with such inputs.
I do not find such oddities mentioned anywhere in the official site. Though I found one other person having the same problem. This problem is easily fixable and I am interested in finding out other such odd changes that had happened in JDK 6.