Avoid I/O during DexPathList.Element.toString().

toString() was calling path.isDirectory(), which could be a StrictMode
violation (eg. on the main thread) and therefore trigger a crash.

This CL moves the check for path.isDirectory() from toString into the
constructors. Note that when dexFile == path == null, then toString()
will throw NPE both before and after this CL; invoking constructors
that allow this to happen is only possible via reflection; a follow-up
CL rules this out.

URL findResource(String name) continues to perform I/O, but that
(and I/O during construction) appears more reasonable than during
toString().

I plan to rely on empirical observation (after this CL is submitted)
rather than code analysis to confirm whether this CL is sufficient to
resolve the associated bugs.

Bug: 120099466
Bug: 77611513
Test: Treehugger
Change-Id: I35a771f5891775e6dd77d98cbb09a18a85179e18
1 file changed