Summary
There is a serious error in the JDK 1.5 compiler, pointed out to me by one of my readers, Amotz Anner. Using final local variables in conjunction with ternary if-else where one side of the values is null, leads to incorrect results.

Amotz has submitted a bug report already to Sun, and as soon as we have a number from Sun (may take up to three weeks) we will post that in a follow-up.

Here is the problem:

final String name = false ? "Heinz" : null;
System.out.println(name);

When compiled using the JDK 1.5 compiler, it will print out "Heinz". It does not matter whether you say -source 1.[234] or whether you run it using any of the JDK 1.[2345].x JVMs from Sun.

This happens only when the local variable is set to "final" and one of the values of the ternary if-else is literal null.

PLEASE let's not make this into a mud-slinging match against Sun Microsystems, ok? They are overloaded with bug reports as it is. The reason that I post this is to make you aware to NOT use the final local variables in combination with ternary if-else.