Commit bce13c50 authored by Tobias Thierer's avatar Tobias Thierer
Browse files

Fix NPE in URLClassLoader.getPermissions() introduced in Android N.

From Android N until before this CL, URLClassLoader.getPermissions()
could throw NPE because it unconditionally called endsWith() on the
return value of FilePermission.getName(), which is stubbed to return
null on Android. This CL fixes this by un-stubbing getName() to
instead return the value that was passed to the constructor.
Before Android N, URLClassLoader.getPermissions() used URL.getFile()
rather than FilePermission.getName() to get the file path.

Bug: 37380202
Test: Checked that
      OldURLClassLoaderTest#test_getPermissions_fileURLConnection_doesNotThrow
      passes after this CL, but encounters NullPointerException during
      the getPermissions() call, when run on Android versions built
      before this CL (checked both immediately before this CL and on
      Android 7.0 Nougat).

Change-Id: I77f853c468a2f4f276e88464fcad10306f2a52bf
parent 6ea6973d
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment