by on_and_off · 7y ago · 0 comments
Is that an ART/Dalvik feature ?
Yes, ART has had this for a few years now. For example in Oreo this code:
static Integer nums[] = new Integer[100];
public static String stabSelf() {
return nums[new Random().nextInt(100)].toString();
}
Will produce this exception: Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.Integer.toString()' on a null object referencethe name of the method causing the crash (toString in that sample) + the line number and location thanks to the stacktrace (although in some rare case it is 100% accurate, but still pretty close, maybe that's due to runtime inlining) and it is very trivial to know where the exception comes from.
Nice humble brag. :D