Ensure JNI primitive array type is appropriate.
Check the primitive array type for GetPrimitiveArray, ReleasePrimitiveArray,
GetPrimitiveArrayRegion and SetPrimitiveArrayRegion matches the given array
type. Check the GetPrimitiveArrayCritical and ReleasePrimitiveArrayCritical are
given a primitive array.
Add unit tests that null parameters lead to fatal errors, not crashes. Fix
issues where CheckJNI assumed non-null arguments.
Tidy testing code via the use of nullptr. Add a few extra checks.
Ensure arrays of void are not able to be created, use RI compatible
NoClassDefError.
Bug: 14817823
Change-Id: I9903bcd800d0da1988ced07f61fb97b783c5deab
diff --git a/runtime/mirror/array.h b/runtime/mirror/array.h
index eead4eb..1e72a0b 100644
--- a/runtime/mirror/array.h
+++ b/runtime/mirror/array.h
@@ -155,14 +155,19 @@
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
static void SetArrayClass(Class* array_class) {
- CHECK(array_class_ == NULL);
- CHECK(array_class != NULL);
+ CHECK(array_class_ == nullptr);
+ CHECK(array_class != nullptr);
array_class_ = array_class;
}
+ static Class* GetArrayClass() {
+ DCHECK(array_class_ != nullptr);
+ return array_class_;
+ }
+
static void ResetArrayClass() {
- CHECK(array_class_ != NULL);
- array_class_ = NULL;
+ CHECK(array_class_ != nullptr);
+ array_class_ = nullptr;
}
static void VisitRoots(RootCallback* callback, void* arg)