MCPcopy
hub / github.com/google/guava / lenientToString

Method lenientToString

guava/src/com/google/common/base/Strings.java:303–319  ·  view source on GitHub ↗
(@Nullable Object o)

Source from the content-addressed store, hash-verified

301 }
302
303 @SuppressWarnings("CatchingUnchecked") // sneaky checked exception
304 private static String lenientToString(@Nullable Object o) {
305 if (o == null) {
306 return "null";
307 }
308 try {
309 return o.toString();
310 } catch (Exception e) { // sneaky checked exception
311 // Default toString() behavior - see Object.toString()
312 String objectToString =
313 o.getClass().getName() + '@' + Integer.toHexString(System.identityHashCode(o));
314 // Logger is created inline with fixed name to avoid forcing Proguard to create another class.
315 Logger.getLogger("com.google.common.base.Strings")
316 .log(WARNING, "Exception during lenientFormat for " + objectToString, e);
317 return "<" + objectToString + " threw " + e.getClass().getName() + ">";
318 }
319 }
320}

Callers 1

lenientFormatMethod · 0.95

Calls 4

toStringMethod · 0.65
getNameMethod · 0.45
identityHashCodeMethod · 0.45
logMethod · 0.45

Tested by

no test coverage detected