Implicit NPE support when no exception given to throw.
This change adds support for creating an implicit NPE when throw is used
without giving an exception object. It extends the CatchTest to check
the functionality is correct. It also weakens a too strong assertion
about when an address lies within code.
Change-Id: I33742cce4deb31b4e0e9b7bd386f78e8cba3e53a
diff --git a/src/thread.cc b/src/thread.cc
index 69fb3ba..e1207d0 100644
--- a/src/thread.cc
+++ b/src/thread.cc
@@ -68,6 +68,10 @@
// Place a special frame at the TOS that will save all callee saves
*sp = thread->CalleeSaveMethod();
thread->SetTopOfStack(sp, 0);
+ if (exception == NULL) {
+ thread->ThrowNewException("Ljava/lang/NullPointerException;", "throw with null exception");
+ exception = thread->GetException();
+ }
thread->DeliverException(exception);
}