diff options
| author | Nicolas Geoffray <ngeoffray@google.com> | 2017-12-09 12:48:04 +0000 |
|---|---|---|
| committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2017-12-09 12:48:04 +0000 |
| commit | 3c76c9ae056400b2fd7bd5909434dce66f303a17 (patch) | |
| tree | d7c52ce037a9c67a4cfc863d7b76c8e8044b4005 | |
| parent | d70e6c1fca13abae80c4e1d888d93405e5ae54d4 (diff) | |
| parent | 70b5ca959d6bfe554d92ea58596f93cecfe74362 (diff) | |
| download | platform_libnativehelper-3c76c9ae056400b2fd7bd5909434dce66f303a17.tar.gz platform_libnativehelper-3c76c9ae056400b2fd7bd5909434dce66f303a17.tar.bz2 platform_libnativehelper-3c76c9ae056400b2fd7bd5909434dce66f303a17.zip | |
Merge "Revert "Switch fatalError to NPE""
| -rw-r--r-- | header_only_include/nativehelper/scoped_primitive_array.h | 8 | ||||
| -rw-r--r-- | tests/scoped_primitive_array_test.cpp | 26 |
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 982f424..17f18a3 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 throwNullPointerException(JNIEnv* env) { \ - jniThrowNullPointerException(env, nullptr); \ + static inline void fatalError(JNIEnv* env, const char*msg) { \ + env->FatalError(msg); \ } \ using ArrayType = ARRAY_TYPE; \ }; \ @@ -84,7 +84,7 @@ public: mSize = -1; mRawArray = nullptr; if (!kNullable) { - Traits::throwNullPointerException(mEnv); + Traits::fatalError(mEnv, "javaArray is null"); } } else { mSize = Traits::getArrayLength(mEnv, mJavaArray); @@ -166,7 +166,7 @@ public: ScopedArrayRW(JNIEnv* env, ArrayType javaArray) : mEnv(env), mJavaArray(javaArray) { if (mJavaArray == nullptr) { - Traits::throwNullPointerException(mEnv); + Traits::fatalError(mEnv, "javaArray is null"); } 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 d75a880..cba258c 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 NPEThrown = false; + bool aborted = false; bool elementsUpdated = false; void resetCallCount() { getArrayElementsCallCount = 0; releaseArrayElementsCallCount = 0; - NPEThrown = false; + aborted = false; elementsUpdated = false; } @@ -72,8 +72,8 @@ public: return array == LARGE_ARRAY ? LARGE_ARRAY_SIZE : SMALL_ARRAY_SIZE; } - static inline void throwNullPointerException(JNIEnv* env) { - reinterpret_cast<TestContext*>(env)->NPEThrown = true; + static inline void fatalError(JNIEnv* env, const char*) { + reinterpret_cast<TestContext*>(env)->aborted = true; } using ArrayType = jTestTypeArray; @@ -99,7 +99,7 @@ TEST(ScopedPrimitiveArrayTest, testNonNullArray) { } EXPECT_EQ(context.getArrayElementsCallCount, context.releaseArrayElementsCallCount); EXPECT_FALSE(context.memoryUpdated()); - EXPECT_FALSE(context.NPEThrown); + EXPECT_FALSE(context.aborted); } { context.resetCallCount(); @@ -114,13 +114,13 @@ TEST(ScopedPrimitiveArrayTest, testNonNullArray) { } EXPECT_EQ(context.getArrayElementsCallCount, context.releaseArrayElementsCallCount); EXPECT_FALSE(context.memoryUpdated()); - EXPECT_FALSE(context.NPEThrown); + EXPECT_FALSE(context.aborted); } { context.resetCallCount(); { ScopedArrayRO<TestType, false /* non null */> array(env, nullptr); - EXPECT_TRUE(context.NPEThrown); + EXPECT_TRUE(context.aborted); } } } @@ -145,7 +145,7 @@ TEST(ScopedPrimitiveArrayTest, testNullableArray) { } EXPECT_EQ(context.getArrayElementsCallCount, context.releaseArrayElementsCallCount); EXPECT_FALSE(context.memoryUpdated()); - EXPECT_FALSE(context.NPEThrown); + EXPECT_FALSE(context.aborted); } { context.resetCallCount(); @@ -159,7 +159,7 @@ TEST(ScopedPrimitiveArrayTest, testNullableArray) { } EXPECT_EQ(context.getArrayElementsCallCount, context.releaseArrayElementsCallCount); EXPECT_FALSE(context.memoryUpdated()); - EXPECT_FALSE(context.NPEThrown); + EXPECT_FALSE(context.aborted); } { context.resetCallCount(); @@ -173,7 +173,7 @@ TEST(ScopedPrimitiveArrayTest, testNullableArray) { } EXPECT_EQ(context.getArrayElementsCallCount, context.releaseArrayElementsCallCount); EXPECT_FALSE(context.memoryUpdated()); - EXPECT_FALSE(context.NPEThrown); + EXPECT_FALSE(context.aborted); } } @@ -197,7 +197,7 @@ TEST(ScopedPrimitiveArrayTest, testArrayRW) { } EXPECT_EQ(context.getArrayElementsCallCount, context.releaseArrayElementsCallCount); EXPECT_TRUE(context.memoryUpdated()); - EXPECT_FALSE(context.NPEThrown); + EXPECT_FALSE(context.aborted); } { context.resetCallCount(); @@ -211,13 +211,13 @@ TEST(ScopedPrimitiveArrayTest, testArrayRW) { } EXPECT_EQ(context.getArrayElementsCallCount, context.releaseArrayElementsCallCount); EXPECT_TRUE(context.memoryUpdated()); - EXPECT_FALSE(context.NPEThrown); + EXPECT_FALSE(context.aborted); } { context.resetCallCount(); { ScopedArrayRW<TestType> array(env, nullptr); - EXPECT_TRUE(context.NPEThrown); + EXPECT_TRUE(context.aborted); } } } |
