summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/JniTest/JniTest.java3
-rw-r--r--test/JniTest/jni_test.cc12
2 files changed, 15 insertions, 0 deletions
diff --git a/test/JniTest/JniTest.java b/test/JniTest/JniTest.java
index 9194da581f..d53cf5e564 100644
--- a/test/JniTest/JniTest.java
+++ b/test/JniTest/JniTest.java
@@ -23,6 +23,7 @@ class JniTest {
testFindFieldOnAttachedNativeThread();
testCallStaticVoidMethodOnSubClass();
testGetMirandaMethod();
+ testZeroLengthByteBuffers();
}
private static native void testFindClassOnAttachedNativeThread();
@@ -67,6 +68,8 @@ class JniTest {
}
}
+ private static native void testZeroLengthByteBuffers();
+
private static abstract class testGetMirandaMethod_MirandaAbstract implements testGetMirandaMethod_MirandaInterface {
public boolean inAbstract() {
return true;
diff --git a/test/JniTest/jni_test.cc b/test/JniTest/jni_test.cc
index d15e180c02..33af94b2ab 100644
--- a/test/JniTest/jni_test.cc
+++ b/test/JniTest/jni_test.cc
@@ -17,6 +17,7 @@
#include <assert.h>
#include <stdio.h>
#include <pthread.h>
+#include <vector>
#include "jni.h"
@@ -125,3 +126,14 @@ extern "C" JNIEXPORT jobject JNICALL Java_JniTest_testGetMirandaMethodNative(JNI
assert(miranda_method != NULL);
return env->ToReflectedMethod(abstract_class, miranda_method, JNI_FALSE);
}
+
+// https://code.google.com/p/android/issues/detail?id=63055
+extern "C" void JNICALL Java_JniTest_testZeroLengthByteBuffers(JNIEnv* env, jclass) {
+ std::vector<uint8_t> buffer(1);
+ jobject byte_buffer = env->NewDirectByteBuffer(&buffer[0], 0);
+ assert(byte_buffer != NULL);
+ assert(!env->ExceptionCheck());
+
+ assert(env->GetDirectBufferAddress(byte_buffer) == &buffer[0]);
+ assert(env->GetDirectBufferCapacity(byte_buffer) == 0);
+}