System.out.println("foo" + s != null ? s : ""); precedence

Tom Tromey tromey@redhat.com
Wed Aug 15 14:36:00 GMT 2001


>>>>> "Alex" == Alexandre Petit-Bianco <apbianco@cygnus.com> writes:

>> It's wrong with 3.0 too. 

Alex> And guess what. It's wrong with Sun's JDK1.1.2 and JDK1.1.8. An
Alex> old version of jikes I found also behaves the same way. I guess
Alex> the bug is in Sun's grammar specification. I wonder if it's stil
Alex> there with in Sun's 1.3...

How do we know it is a bug?

It seems to me that the reference grammar in JLS 2nd Ed. specifies the
current behavior.  However, the JLS is suprisingly hard to read here,
so I could very well be misreading it.  I didn't see a nice table of
operator precedence anywhere.

"The Java Programming Language" (not canonical, but maybe useful) does
have a table of operator precedence; it shows binary `+' having
precedence over `?:'.

Maybe I've missed something obvious?
Does Jacks have a test for this?

Tom



More information about the Java mailing list