"" + null should be null (or throw an exception). Null is null and nothing else.
But still , "" + null being "null" is just plain crazy. I could see "" + null == "" (as you are concatenating nothing to the string), or "" + null == null as you are concatenating a string to null, but "null" is bonkers.
Since the empty String is a valid String, and Strinfg.valueOf() also returns a String, what other behavior would you ever imagine being sane or possible?
IMHO, String.valueOf() throwing NPE upon encountering a null reference would be both sane and possible.
Unfortunately, it does indeed appear that it returns "null" instead [1].
[1] https://docs.oracle.com/javase/7/docs/api/java/lang/String.h...
log.trace("doStuff(" + obj1 + ", " + obj2 + ")");
to this:
log.trace("doStuff(" + (obj1 != null ? obj1 : "null") + ", " + (obj2 != null ? obj2 : "null") + ")");
The second one is IMHO quite hard to read, even in this short example (and code readability is important when you do code reviews)
For string formatting, rendering "null" (or "") makes sense; for coercion not.