This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Abort on null-returning implied toString (was System.out.println....precedence)
Tom Tromey:
> "The Java Programming Language" (not canonical, but maybe useful) does
> have a table of operator precedence; it shows binary `+' having
> precedence over `?:'.
Oops. Sorry.
That said, with today's trunk, an implied toString which returns null will
cause an abort w/ core dump:
public class Test {
public static void main(String args[]) {
System.out.println(new Test());
}
public String toString() { return null; }
}
$ ./test
Aborted (core dumped)
When the toString is explicit it works as I expect:
System.out.println((new Test()).toString());
$ ./test
null
as does println((String)null).