Abort on null-returning implied toString (was System.out.println....precedence)

Mark J Roberts mjr@anarcast.net
Thu Aug 16 10:13:00 GMT 2001


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).


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /