aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSeigo Nonaka <nona@google.com>2017-12-09 02:32:24 +0000
committerandroid-build-merger <android-build-merger@google.com>2017-12-09 02:32:24 +0000
commit4eaaa4d72fd8438585ab5756b77c303cbfc199bb (patch)
treef3bf9b2a4c8f30e7ecd8606fc260e30b5b16a8b4
parent16aff263ce2e06a9d10cd61292a9879d562a04ef (diff)
parent37aebe67e3f18a00b4528ecc4b22ad5c05271443 (diff)
downloadplatform_libnativehelper-4eaaa4d72fd8438585ab5756b77c303cbfc199bb.tar.gz
platform_libnativehelper-4eaaa4d72fd8438585ab5756b77c303cbfc199bb.tar.bz2
platform_libnativehelper-4eaaa4d72fd8438585ab5756b77c303cbfc199bb.zip
Merge "Switch fatalError to NPE" am: d70e6c1fca
am: 37aebe67e3 Change-Id: Ib87a0ccfb1e1742e24850a8436f8f15d5b235ff4
-rw-r--r--header_only_include/nativehelper/scoped_primitive_array.h8
-rw-r--r--tests/scoped_primitive_array_test.cpp26
2 files changed, 17 insertions, 17 deletions
diff --git a/header_only_include/nativehelper/scoped_primitive_array.h b/header_only_include/nativehelper/scoped_primitive_array.h
index 17f18a3..982f424 100644
--- a/header_only_include/nativehelper/scoped_primitive_array.h
+++ b/header_only_include/nativehelper/scoped_primitive_array.h
@@ -51,8 +51,8 @@ public:
static inline size_t getArrayLength(JNIEnv* env, ARRAY_TYPE array) { \
return env->GetArrayLength(array); \
} \
- static inline void fatalError(JNIEnv* env, const char*msg) { \
- env->FatalError(msg); \
+ static inline void throwNullPointerException(JNIEnv* env) { \
+ jniThrowNullPointerException(env, nullptr); \
} \
using ArrayType = ARRAY_TYPE; \
}; \
@@ -84,7 +84,7 @@ public:
mSize = -1;
mRawArray = nullptr;
if (!kNullable) {
- Traits::fatalError(mEnv, "javaArray is null");
+ Traits::throwNullPointerException(mEnv);
}
} else {
mSize = Traits::getArrayLength(mEnv, mJavaArray);
@@ -166,7 +166,7 @@ public:
ScopedArrayRW(JNIEnv* env, ArrayType javaArray) : mEnv(env), mJavaArray(javaArray) {
if (mJavaArray == nullptr) {
- Traits::fatalError(mEnv, "javaArray is null");
+ Traits::throwNullPointerException(mEnv);
} else {
mSize = Traits::getArrayLength(mEnv, mJavaArray);
mRawArray = Traits::getArrayElements(mEnv, mJavaArray);
diff --git a/tests/scoped_primitive_array_test.cpp b/tests/scoped_primitive_array_test.cpp
index cba258c..d75a880 100644
--- a/tests/scoped_primitive_array_test.cpp
+++ b/tests/scoped_primitive_array_test.cpp
@@ -32,13 +32,13 @@ struct TestContext {
int getArrayElementsCallCount = 0;
int releaseArrayElementsCallCount = 0;
- bool aborted = false;
+ bool NPEThrown = false;
bool elementsUpdated = false;
void resetCallCount() {
getArrayElementsCallCount = 0;
releaseArrayElementsCallCount = 0;
- aborted = false;
+ NPEThrown = false;
elementsUpdated = false;
}
@@ -72,8 +72,8 @@ public:
return array == LARGE_ARRAY ? LARGE_ARRAY_SIZE : SMALL_ARRAY_SIZE;
}
- static inline void fatalError(JNIEnv* env, const char*) {
- reinterpret_cast<TestContext*>(env)->aborted = true;
+ static inline void throwNullPointerException(JNIEnv* env) {
+ reinterpret_cast<TestContext*>(env)->NPEThrown = true;
}
using ArrayType = jTestTypeArray;
@@ -99,7 +99,7 @@ TEST(ScopedPrimitiveArrayTest, testNonNullArray) {
}
EXPECT_EQ(context.getArrayElementsCallCount, context.releaseArrayElementsCallCount);
EXPECT_FALSE(context.memoryUpdated());
- EXPECT_FALSE(context.aborted);
+ EXPECT_FALSE(context.NPEThrown);
}
{
context.resetCallCount();
@@ -114,13 +114,13 @@ TEST(ScopedPrimitiveArrayTest, testNonNullArray) {
}
EXPECT_EQ(context.getArrayElementsCallCount, context.releaseArrayElementsCallCount);
EXPECT_FALSE(context.memoryUpdated());
- EXPECT_FALSE(context.aborted);
+ EXPECT_FALSE(context.NPEThrown);
}
{
context.resetCallCount();
{
ScopedArrayRO<TestType, false /* non null */> array(env, nullptr);
- EXPECT_TRUE(context.aborted);
+ EXPECT_TRUE(context.NPEThrown);
}
}
}
@@ -145,7 +145,7 @@ TEST(ScopedPrimitiveArrayTest, testNullableArray) {
}
EXPECT_EQ(context.getArrayElementsCallCount, context.releaseArrayElementsCallCount);
EXPECT_FALSE(context.memoryUpdated());
- EXPECT_FALSE(context.aborted);
+ EXPECT_FALSE(context.NPEThrown);
}
{
context.resetCallCount();
@@ -159,7 +159,7 @@ TEST(ScopedPrimitiveArrayTest, testNullableArray) {
}
EXPECT_EQ(context.getArrayElementsCallCount, context.releaseArrayElementsCallCount);
EXPECT_FALSE(context.memoryUpdated());
- EXPECT_FALSE(context.aborted);
+ EXPECT_FALSE(context.NPEThrown);
}
{
context.resetCallCount();
@@ -173,7 +173,7 @@ TEST(ScopedPrimitiveArrayTest, testNullableArray) {
}
EXPECT_EQ(context.getArrayElementsCallCount, context.releaseArrayElementsCallCount);
EXPECT_FALSE(context.memoryUpdated());
- EXPECT_FALSE(context.aborted);
+ EXPECT_FALSE(context.NPEThrown);
}
}
@@ -197,7 +197,7 @@ TEST(ScopedPrimitiveArrayTest, testArrayRW) {
}
EXPECT_EQ(context.getArrayElementsCallCount, context.releaseArrayElementsCallCount);
EXPECT_TRUE(context.memoryUpdated());
- EXPECT_FALSE(context.aborted);
+ EXPECT_FALSE(context.NPEThrown);
}
{
context.resetCallCount();
@@ -211,13 +211,13 @@ TEST(ScopedPrimitiveArrayTest, testArrayRW) {
}
EXPECT_EQ(context.getArrayElementsCallCount, context.releaseArrayElementsCallCount);
EXPECT_TRUE(context.memoryUpdated());
- EXPECT_FALSE(context.aborted);
+ EXPECT_FALSE(context.NPEThrown);
}
{
context.resetCallCount();
{
ScopedArrayRW<TestType> array(env, nullptr);
- EXPECT_TRUE(context.aborted);
+ EXPECT_TRUE(context.NPEThrown);
}
}
}