Clear pending exception before throwing a new one.

The JNI helper function that throws an exception calls FindClass, which
isn't allowed if an exception is currently pending.  Some of our code
called this when an operation failed without noting that the thing that
failed already threw an exception; this caused the VM to blow up in a
rather unhelpful way.

We now log the class name and optional message from the original
exception, clear it, and then allocate & throw the new one.

For bug 2141867.
1 file changed