Remove message ART creates for "throw null".
The new version of R8 transforms:
throw new NullPointerException()
Into:
throw null
ART used to create a message for the pattern "throw null", which is
something that now breaks ObjectsTest.requireNonNull.
Test: libcore.java.util.ObjectsTest#test_requireNonNull_T
Change-Id: I142ddc74a9c0cfc76d2479eb92078b7a7d077b27
diff --git a/runtime/common_throws.cc b/runtime/common_throws.cc
index a1168af..fdd4f36 100644
--- a/runtime/common_throws.cc
+++ b/runtime/common_throws.cc
@@ -728,6 +728,10 @@
ThrowException("Ljava/lang/NullPointerException;", nullptr, msg);
}
+void ThrowNullPointerException() {
+ ThrowException("Ljava/lang/NullPointerException;");
+}
+
// ReadOnlyBufferException
void ThrowReadOnlyBufferException() {
diff --git a/runtime/common_throws.h b/runtime/common_throws.h
index c167d1b..832eac6 100644
--- a/runtime/common_throws.h
+++ b/runtime/common_throws.h
@@ -234,6 +234,9 @@
void ThrowNullPointerException(const char* msg)
REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
+void ThrowNullPointerException()
+ REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
+
// ReadOnlyBufferException
void ThrowReadOnlyBufferException() REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
diff --git a/runtime/entrypoints/quick/quick_throw_entrypoints.cc b/runtime/entrypoints/quick/quick_throw_entrypoints.cc
index 2e447ec..202b031 100644
--- a/runtime/entrypoints/quick/quick_throw_entrypoints.cc
+++ b/runtime/entrypoints/quick/quick_throw_entrypoints.cc
@@ -54,7 +54,7 @@
*/
ScopedQuickEntrypointChecks sqec(self);
if (exception == nullptr) {
- self->ThrowNewException("Ljava/lang/NullPointerException;", "throw with null exception");
+ self->ThrowNewException("Ljava/lang/NullPointerException;", nullptr);
} else {
self->SetException(exception);
}
diff --git a/runtime/interpreter/interpreter_switch_impl-inl.h b/runtime/interpreter/interpreter_switch_impl-inl.h
index 2ee0512..be4b807 100644
--- a/runtime/interpreter/interpreter_switch_impl-inl.h
+++ b/runtime/interpreter/interpreter_switch_impl-inl.h
@@ -799,7 +799,7 @@
}
ObjPtr<mirror::Object> exception = GetVRegReference(A());
if (UNLIKELY(exception == nullptr)) {
- ThrowNullPointerException("throw with null exception");
+ ThrowNullPointerException();
} else if (do_assignability_check && !exception->GetClass()->IsThrowableClass()) {
// This should never happen.
std::string temp;
diff --git a/test/638-no-line-number/expected.txt b/test/638-no-line-number/expected.txt
index 4b351f4..3b6ff96 100644
--- a/test/638-no-line-number/expected.txt
+++ b/test/638-no-line-number/expected.txt
@@ -1,5 +1,5 @@
java.lang.Error
at Main.main(Unknown Source:2)
-java.lang.NullPointerException: throw with null exception
+java.lang.NullPointerException
at Main.doThrow(Unknown Source:0)
at Main.main(Unknown Source:16)