diff --git a/src/main/cpp/ByteArray.cpp b/src/main/cpp/ByteArray.cpp deleted file mode 100644 index 1bc9fdc..0000000 --- a/src/main/cpp/ByteArray.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (c) 2014 Spotify AB - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#include "ByteArray.h" -#include "JavaExceptionUtils.h" -#include - -namespace spotify { -namespace jni { - -ByteArray::ByteArray() : _data(NULL), _num_bytes(0) {} - -ByteArray::ByteArray(void *data, const size_t numBytes, bool copyData) : -_data(NULL), _num_bytes(0) { - // In the rare (but possible) event that this constructor is called with - // NULL but non-zero length data, correct the byte count so as to avoid - // segfaults later on. - if (data == NULL && numBytes > 0) { - _num_bytes = 0; - } else if (data != NULL && numBytes > 0) { - set(data, numBytes, copyData); - } -} - -ByteArray::ByteArray(JNIEnv *env, jbyteArray data) : -_data(NULL), _num_bytes(0) { - set(env, data); -} - -ByteArray::~ByteArray() { - if (_data != NULL) { - free(_data); - _data = NULL; - } -} - -void *ByteArray::leak() { - void *result = _data; - _data = NULL; - _num_bytes = 0; - return result; -} - -JniLocalRef ByteArray::toJavaByteArray(JNIEnv *env) const { - JniLocalRef result = env->NewByteArray((jsize)_num_bytes); - JavaExceptionUtils::checkException(env); - if (_num_bytes == 0 || _data == NULL) { - return result; - } - env->SetByteArrayRegion(result, 0, (jsize)_num_bytes, (jbyte *)_data); - return result.leak(); -} - -void ByteArray::set(void *data, const size_t numBytes, bool copyData) { - if (data == NULL && numBytes > 0) { - JNIEnv *env = JavaThreadUtils::getEnvForCurrentThread(); - JavaExceptionUtils::throwExceptionOfType(env, kTypeIllegalArgumentException, - "Cannot set data with non-zero size and NULL object"); - return; - } - - // Make sure not to leak the old data if it exists - if (_data != NULL) { - free(_data); - } - - if (copyData) { - _data = malloc(numBytes); - memcpy(_data, data, numBytes); - } else { - _data = data; - } - _num_bytes = numBytes; -} - -void ByteArray::set(JNIEnv *env, jbyteArray data) { - if (_data != NULL) { - free(_data); - } - - if (data != NULL) { - _num_bytes = env->GetArrayLength(data); - if (_num_bytes == 0) { - _data = NULL; - } else { - _data = malloc(_num_bytes); - env->GetByteArrayRegion(data, 0, (jsize)_num_bytes, (jbyte *)_data); - } - } -} - -} // namespace jni -} // namespace spotify diff --git a/src/main/cpp/JavaArray.cpp b/src/main/cpp/JavaArray.cpp new file mode 100644 index 0000000..22d29f6 --- /dev/null +++ b/src/main/cpp/JavaArray.cpp @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2014 Spotify AB + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#include "JavaArray.h" +#include "JavaExceptionUtils.h" +#include + +namespace spotify { +namespace jni { + +} // namespace jni +} // namespace spotify diff --git a/src/main/cpp/ByteArray.h b/src/main/cpp/JavaArray.h similarity index 57% rename from src/main/cpp/ByteArray.h rename to src/main/cpp/JavaArray.h index 085e676..1b3c483 100644 --- a/src/main/cpp/ByteArray.h +++ b/src/main/cpp/JavaArray.h @@ -19,8 +19,8 @@ * under the License. */ -#ifndef __ByteArray_h__ -#define __ByteArray_h__ +#ifndef __JavaArray_h__ +#define __JavaArray_h__ #include "JniHelpersCommon.h" #include "JniLocalRef.h" @@ -34,12 +34,13 @@ namespace jni { * This class is used for passing raw data arrays through JNI. Internally * the data is stored as a void*. */ -class EXPORT ByteArray { +template +class EXPORT JavaArray { public: /** * @brief Create a new empty byte array */ - ByteArray(); + JavaArray() : _data(NULL), _num_elements(0) {} /** * @brief Create a new byte array with data. @@ -48,37 +49,50 @@ class EXPORT ByteArray { * @param copyData True if the data should be copied to this instance * * See the documentation for set() regarding the ownership of data stored - * in ByteArray instances. + * in JavaArray instances. */ - ByteArray(void *data, const size_t numBytes, bool copyData); - - /** - * @brief Create a new byte array with data from a Java byte[] object - * @param env JNIEnv - * @param data Java byte[] data - */ - ByteArray(JNIEnv *env, jbyteArray data); - - virtual ~ByteArray(); + JavaArray(NativeType data, const size_t numElements, bool copyData) : + _data(NULL), _num_elements(0) { + // In the rare (but possible) event that this constructor is called with + // NULL but non-zero length data, correct the byte count so as to avoid + // segfaults later on. + if (data == NULL && numElements > 0) { + _num_bytes = 0; + } else if (data != NULL && numElements > 0) { + set(data, numElements, copyData); + } + } + + virtual ~JavaArray() { + if (_data != NULL) { + free(_data); + _data = NULL; + } + } /** * @brief Get a pointer to the natively stored data */ - const void* get() const { return _data; } + virtual const NativeType get() const { return _data; } /** * @brief Convert data to a Java byte[] array */ - JniLocalRef toJavaByteArray(JNIEnv *env) const; + virtual JniLocalRef toJavaArray(JNIEnv *env) const = 0; /** * @brief Return a pointer to the data stored by this instance * - * When an instance of ByteArray is destroyed, it will attempt to free + * When an instance of JavaArray is destroyed, it will attempt to free * the data stored internally. If this data is still needed elsewhere, * then you should call leak() or else it will be unavailable. */ - void *leak(); + virtual NativeType leak() { + NativeType result = _data; + _data = NULL; + _num_elements = 0; + return result; + } /** * @brief Store data in this instance @@ -86,44 +100,66 @@ class EXPORT ByteArray { * @param numBytes Size of data pointed to * @param copyData True if the data should be copied to this instance * - * If copyData is true, then this ByteArray instance owns that data and + * If copyData is true, then this JavaArray instance owns that data and * the original data passed to this method can be freed without worry. - * However, if copyData is false, then this ByteArray effectively just + * However, if copyData is false, then this JavaArray effectively just * points to that instance instead. In either case, after setting data - * in a ByteArray, it effectively owns that data. + * in a JavaArray, it effectively owns that data. * - * When this ByteArray is destroyed, it will free the data stored in it, + * When this JavaArray is destroyed, it will free the data stored in it, * regardless of how it has been set. This means that if copyData was * false and that data is still needed elsewhere, then a segfault will * probably occur when attempting to access that data after this object * has been destroyed. Thus, the leak() method can be used to remedy the - * situation by removing the pointer to the data so the ByteArray will + * situation by removing the pointer to the data so the JavaArray will * not free it upon destruction. * * It is obviously more efficient to not copy the data, however this can * cause problems if your code does not respect the ownership behaviors * described above. */ - void set(void *data, const size_t numBytes, bool copyData); + virtual void set(NativeType data, const size_t numElements, bool copyData) { + if (data == NULL && numElements > 0) { + JNIEnv *env = JavaThreadUtils::getEnvForCurrentThread(); + JavaExceptionUtils::throwExceptionOfType(env, kTypeIllegalArgumentException, + "Cannot set data with non-zero size and NULL object"); + return; + } + + // Make sure not to leak the old data if it exists + if (_data != NULL) { + free(_data); + } + + if (copyData) { + size_t numBytes = numElements * sizeof(NativeType); + _data = malloc(numBytes); + memcpy(_data, data, numBytes); + } else { + _data = data; + } + + _num_elements = numElements; + } /** * @brief Store data in this instance from a Java byte[] array * @param env JNIenv * @param data Java byte[] array */ - void set(JNIEnv *env, jbyteArray data); + virtual void set(JNIEnv *env, JavaType data) = 0; /** * @brief Get the size of the data stored by this instance */ - const size_t size() const { return _num_bytes; } + virtual const size_t size() const { return _num_elements; } -private: - void *_data; - size_t _num_bytes; +protected: + NativeType _data; + size_t _num_elements; }; } // namespace jni } // namespace spotify -#endif // __ByteArray_h__ +#endif // __JavaArray_h__ diff --git a/src/main/cpp/JavaByteArray.h b/src/main/cpp/JavaByteArray.h new file mode 100644 index 0000000..3ef8a0d --- /dev/null +++ b/src/main/cpp/JavaByteArray.h @@ -0,0 +1,48 @@ +#ifndef __JavaByteArray_h__ +#define __JavaByteArray_h__ + +#include "JniHelpersCommon.h" +#include "JavaArray.h" + +namespace spotify { +namespace jni { +namespace detail { + +template +class EXPORT JavaByteArray : public JavaArray { +public: + JniLocalRef toJavaArray(JNIEnv *env) const { + JniLocalRef result = env->NewByteArray((jsize)_num_elements); + JavaExceptionUtils::checkException(env); + if (_num_elements == 0 || _data == NULL) { + return result; + } + env->SetByteArrayRegion(result, 0, (jsize)_num_elements, (jbyte *)_data); + return result.leak(); + } + + void set(JNIEnv *env, JavaType data) { + if (_data != NULL) { + free(_data); + } + + if (data != NULL) { + _num_elements = env->GetArrayLength(data); + if (_num_elements == 0) { + _data = NULL; + } else { + _data = malloc(_num_elements * sizeof(jbyte)); + env->GetByteArrayRegion(data, 0, (jsize)_num_elements, (jbyte *)_data); + } + } + } +}; + +} // namespace detail + +typedef detail::JavaByteArray JavaByteArray; + +} // namespace jni +} // namespace spotify + +#endif // __JavaByteArray_h__ \ No newline at end of file diff --git a/src/main/cpp/JavaCharArray.h b/src/main/cpp/JavaCharArray.h new file mode 100644 index 0000000..07f8962 --- /dev/null +++ b/src/main/cpp/JavaCharArray.h @@ -0,0 +1,48 @@ +#ifndef __JavaCharArray_h__ +#define __JavaCharArray_h__ + +#include "JniHelpersCommon.h" +#include "JavaArray.h" + +namespace spotify { +namespace jni { +namespace detail { + +template +class EXPORT JavaCharArray : public JavaArray { +public: + JniLocalRef toJavaArray(JNIEnv *env) const { + JniLocalRef result = env->NewCharArray((jsize)_num_elements); + JavaExceptionUtils::checkException(env); + if (_num_elements == 0 || _data == NULL) { + return result; + } + env->SetCharArrayRegion(result, 0, (jsize)_num_elements, (jchar *)_data); + return result.leak(); + } + + void set(JNIEnv *env, JavaType data) { + if (_data != NULL) { + free(_data); + } + + if (data != NULL) { + _num_elements = env->GetArrayLength(data); + if (_num_elements == 0) { + _data = NULL; + } else { + _data = malloc(_num_elements * sizeof(jchar)); + env->GetCharArrayRegion(data, 0, (jsize)_num_elements, (jchar *)_data); + } + } + } +}; + +} // namespace detail + +typedef detail::JavaCharArray JavaCharArray; + +} // namespace jni +} // namespace spotify + +#endif // __JavaCharArray_h__ \ No newline at end of file diff --git a/src/main/cpp/JniHelpers.h b/src/main/cpp/JniHelpers.h index ddc0c74..91ed6fe 100644 --- a/src/main/cpp/JniHelpers.h +++ b/src/main/cpp/JniHelpers.h @@ -24,9 +24,9 @@ #include "JniHelpersCommon.h" -#include "ByteArray.h" -#include "JavaClass.h" #include "ClassRegistry.h" +#include "JavaArray.h" +#include "JavaClass.h" #include "JavaClassUtils.h" #include "JavaExceptionUtils.h" #include "JavaString.h" diff --git a/src/test/cpp/ByteArrayTest.cpp b/src/test/cpp/JavaArrayTest.cpp similarity index 77% rename from src/test/cpp/ByteArrayTest.cpp rename to src/test/cpp/JavaArrayTest.cpp index 3f27840..56266ae 100644 --- a/src/test/cpp/ByteArrayTest.cpp +++ b/src/test/cpp/JavaArrayTest.cpp @@ -19,13 +19,13 @@ * under the License. */ -#include "ByteArrayTest.h" +#include "JavaArrayTest.h" #include "JUnitUtils.h" -#include "ByteArray.h" +#include "JavaArray.h" -void ByteArrayTest::initialize(JNIEnv *env) { +void JavaArrayTest::initialize(JNIEnv *env) { setClass(env); - +#if 0 addNativeMethod("createNewByteArray", (void*)createNewByteArray, kTypeVoid, NULL); addNativeMethod("createNewByteArrayWithData", (void*)createNewByteArrayWithData, kTypeVoid, NULL); addNativeMethod("createNewByteArrayWithDataCopy", (void*)createNewByteArrayWithData, kTypeVoid, NULL); @@ -36,11 +36,11 @@ void ByteArrayTest::initialize(JNIEnv *env) { addNativeMethod("setData", (void*)setData, kTypeVoid, NULL); addNativeMethod("setDataWithCopy", (void*)setData, kTypeVoid, NULL); addNativeMethod("nativeSetJavaByteArray", (void*)nativeSetJavaByteArray, kTypeVoid, kTypeArray(kTypeByte), kTypeInt, NULL); - +#endif registerNativeMethods(env); } - -void* ByteArrayTest::getTestData() { +#if 0 +void* JavaArrayTest::getTestData() { char *result = (char*)malloc(getTestDataSize()); for (size_t i = 0; i < getTestDataSize(); i++) { result[i] = (char)i; @@ -48,71 +48,71 @@ void* ByteArrayTest::getTestData() { return result; } -size_t ByteArrayTest::getTestDataSize() { +size_t JavaArrayTest::getTestDataSize() { return 10; } -void ByteArrayTest::createNewByteArray(JNIEnv *env, jobject javaThis) { - ByteArray byteArray; +void JavaArrayTest::createNewByteArray(JNIEnv *env, jobject javaThis) { + JavaArray byteArray; JUNIT_ASSERT_EQUALS_INT(0, byteArray.size()); JUNIT_ASSERT_NULL(byteArray.get()); } -void ByteArrayTest::createNewByteArrayWithData(JNIEnv *env, jobject javaThis) { +void JavaArrayTest::createNewByteArrayWithData(JNIEnv *env, jobject javaThis) { void *data = getTestData(); - ByteArray byteArray(data, getTestDataSize(), false); + JavaArray byteArray(data, getTestDataSize(), false); JUNIT_ASSERT_EQUALS_INT(getTestDataSize(), byteArray.size()); JUNIT_ASSERT_EQUALS_ARRAY(data, byteArray.get(), byteArray.size()); } -void ByteArrayTest::createNewByteArrayWithDataCopy(JNIEnv *env, jobject javaThis) { +void JavaArrayTest::createNewByteArrayWithDataCopy(JNIEnv *env, jobject javaThis) { void *data = getTestData(); - ByteArray byteArray(data, getTestDataSize(), true); + JavaArray byteArray(data, getTestDataSize(), true); free(data); void *expected = getTestData(); JUNIT_ASSERT_EQUALS_INT(getTestDataSize(), byteArray.size()); JUNIT_ASSERT_EQUALS_ARRAY(expected, byteArray.get(), byteArray.size()); } -void ByteArrayTest::nativeCreateNewByteArrayWithJavaData(JNIEnv *env, jobject javaThis, jbyteArray javaData) { +void JavaArrayTest::nativeCreateNewByteArrayWithJavaData(JNIEnv *env, jobject javaThis, jbyteArray javaData) { void *data = getTestData(); - ByteArray byteArray(env, javaData); + JavaArray byteArray(env, javaData); JUNIT_ASSERT_EQUALS_INT(getTestDataSize(), byteArray.size()); JUNIT_ASSERT_EQUALS_ARRAY(data, byteArray.get(), byteArray.size()); } -void ByteArrayTest::createNewByteArrayWithNull(JNIEnv *env, jobject javaThis) { - ByteArray byteArray(env, (jbyteArray)NULL); +void JavaArrayTest::createNewByteArrayWithNull(JNIEnv *env, jobject javaThis) { + JavaArray byteArray(env, (jbyteArray)NULL); JUNIT_ASSERT_EQUALS_INT(0, byteArray.size()); JUNIT_ASSERT_NULL(byteArray.get()); } -void ByteArrayTest::createNewByteArrayWithNullAndNonZeroLength(JNIEnv *env, jobject javaThis) { - ByteArray byteArray(NULL, 1, false); +void JavaArrayTest::createNewByteArrayWithNullAndNonZeroLength(JNIEnv *env, jobject javaThis) { + JavaArray byteArray(NULL, 1, false); JUNIT_ASSERT_EQUALS_INT(0, byteArray.size()); JUNIT_ASSERT_NULL(byteArray.get()); } -jbyteArray ByteArrayTest::nativeGetTestJavaByteArray(JNIEnv *env, jobject javaThis) { +jbyteArray JavaArrayTest::nativeGetTestJavaByteArray(JNIEnv *env, jobject javaThis) { void *data = getTestData(); - ByteArray byteArray(data, getTestDataSize(), true); + JavaArray byteArray(data, getTestDataSize(), true); JUNIT_ASSERT_EQUALS_INT(getTestDataSize(), byteArray.size()); JUNIT_ASSERT_EQUALS_ARRAY(data, byteArray.get(), byteArray.size()); JniLocalRef result = byteArray.toJavaByteArray(env); return result.leak(); } -void ByteArrayTest::setData(JNIEnv *env, jobject javaThis) { +void JavaArrayTest::setData(JNIEnv *env, jobject javaThis) { void *data = getTestData(); - ByteArray byteArray; + JavaArray byteArray; byteArray.set(data, getTestDataSize(), false); JUNIT_ASSERT_EQUALS_INT(getTestDataSize(), byteArray.size()); JUNIT_ASSERT_EQUALS_ARRAY(data, byteArray.get(), byteArray.size()); } -void ByteArrayTest::setDataWithCopy(JNIEnv *env, jobject javaThis) { +void JavaArrayTest::setDataWithCopy(JNIEnv *env, jobject javaThis) { void *data = getTestData(); - ByteArray byteArray; + JavaArray byteArray; byteArray.set(data, getTestDataSize(), true); // Write 0's over the original data to make sure that a false positive // doesn't cause the test to pass. @@ -123,10 +123,11 @@ void ByteArrayTest::setDataWithCopy(JNIEnv *env, jobject javaThis) { free(expectedData); } -void ByteArrayTest::nativeSetJavaByteArray(JNIEnv *env, jobject javaThis, jbyteArray javaData, jint expectedSize) { +void JavaArrayTest::nativeSetJavaByteArray(JNIEnv *env, jobject javaThis, jbyteArray javaData, jint expectedSize) { void *data = getTestData(); - ByteArray byteArray; + JavaArray byteArray; byteArray.set(env, javaData); JUNIT_ASSERT_EQUALS_INT(expectedSize, byteArray.size()); JUNIT_ASSERT_EQUALS_ARRAY(data, byteArray.get(), byteArray.size()); } +#endif \ No newline at end of file diff --git a/src/test/cpp/ByteArrayTest.h b/src/test/cpp/JavaArrayTest.h similarity index 85% rename from src/test/cpp/ByteArrayTest.h rename to src/test/cpp/JavaArrayTest.h index 9cf21db..ede20f6 100644 --- a/src/test/cpp/ByteArrayTest.h +++ b/src/test/cpp/JavaArrayTest.h @@ -19,27 +19,28 @@ * under the License. */ -#ifndef __ByteArrayTest_h__ -#define __ByteArrayTest_h__ +#ifndef __JavaArrayTest_h__ +#define __JavaArrayTest_h__ #include "JniHelpers.h" #include "JniHelpersTest.h" using namespace spotify::jni; -class ByteArrayTest : public JavaClass { +class JavaArrayTest : public JavaClass { public: - ByteArrayTest() : JavaClass() {} - ByteArrayTest(JNIEnv *env) : JavaClass(env) { initialize(env); } - ~ByteArrayTest() {} + JavaArrayTest() : JavaClass() {} + JavaArrayTest(JNIEnv *env) : JavaClass(env) { initialize(env); } + ~JavaArrayTest() {} const char* getCanonicalName() const { - return MAKE_CANONICAL_NAME(PACKAGE, ByteArrayTest); + return MAKE_CANONICAL_NAME(PACKAGE, JavaArrayTest); } void initialize(JNIEnv *env); void mapFields() {} private: +#if 0 static void* getTestData(); static size_t getTestDataSize(); @@ -53,6 +54,7 @@ class ByteArrayTest : public JavaClass { static void setData(JNIEnv *env, jobject javaThis); static void setDataWithCopy(JNIEnv *env, jobject javaThis); static void nativeSetJavaByteArray(JNIEnv *env, jobject javaThis, jbyteArray javaData, jint expectedSize); +#endif }; -#endif // __ByteArrayTest_h__ +#endif // __JavaArrayTest_h__ diff --git a/src/test/cpp/JavaByteArrayTest.cpp b/src/test/cpp/JavaByteArrayTest.cpp new file mode 100644 index 0000000..7f8cad0 --- /dev/null +++ b/src/test/cpp/JavaByteArrayTest.cpp @@ -0,0 +1,7 @@ +#include "JavaByteArrayTest.h" +#include "JavaByteArray.h" + +void JavaByteArrayTest::initialize(JNIEnv *env) { + setClass(env); + JavaByteArray foo; +} \ No newline at end of file diff --git a/src/test/cpp/JavaByteArrayTest.h b/src/test/cpp/JavaByteArrayTest.h new file mode 100644 index 0000000..219797b --- /dev/null +++ b/src/test/cpp/JavaByteArrayTest.h @@ -0,0 +1,22 @@ +#ifndef __JavaByteArrayTest_h__ +#define __JavaByteArrayTest_h__ + +#include "JniHelpers.h" +#include "JniHelpersTest.h" + +using namespace spotify::jni; + +class JavaByteArrayTest : public JavaClass { +public: + JavaByteArrayTest() : JavaClass() {} + JavaByteArrayTest(JNIEnv *env) : JavaClass(env) {} + ~JavaByteArrayTest() {} + + const char *getCanonicalName() const { + return MAKE_CANONICAL_NAME(PACKAGE, JavaByteArrayTest); + } + void initialize(JNIEnv *env); + void mapFields() {} +}; + +#endif // __JavaByteArrayTest_h__ diff --git a/src/test/cpp/JavaCharArrayTest.cpp b/src/test/cpp/JavaCharArrayTest.cpp new file mode 100644 index 0000000..e69de29 diff --git a/src/test/cpp/JavaCharArrayTest.h b/src/test/cpp/JavaCharArrayTest.h new file mode 100644 index 0000000..e69de29 diff --git a/src/test/cpp/JniHelpersTest.cpp b/src/test/cpp/JniHelpersTest.cpp index 5a666f0..6c92715 100644 --- a/src/test/cpp/JniHelpersTest.cpp +++ b/src/test/cpp/JniHelpersTest.cpp @@ -20,8 +20,8 @@ */ #include "JniHelpersTest.h" -#include "ByteArrayTest.h" #include "ClassRegistryTest.h" +#include "JavaArrayTest.h" #include "JavaClassTest.h" #include "JavaClassUtilsTest.h" #include "JavaExceptionUtilsTest.h" @@ -39,8 +39,8 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *jvm, void*) { return -1; } - gClasses.add(env, new ByteArrayTest(env)); gClasses.add(env, new ClassRegistryTest(env)); + gClasses.add(env, new JavaArrayTest(env)); gClasses.add(env, new JavaClassTest(env)); gClasses.add(env, new JavaClassUtilsTest(env)); gClasses.add(env, new JavaExceptionUtilsTest(env)); diff --git a/src/test/java/com/spotify/jni/ByteArrayTest.java b/src/test/java/com/spotify/jni/JavaArrayTest.java similarity index 98% rename from src/test/java/com/spotify/jni/ByteArrayTest.java rename to src/test/java/com/spotify/jni/JavaArrayTest.java index 16f122d..da62dd6 100644 --- a/src/test/java/com/spotify/jni/ByteArrayTest.java +++ b/src/test/java/com/spotify/jni/JavaArrayTest.java @@ -25,7 +25,7 @@ import static org.junit.Assert.assertEquals; -public class ByteArrayTest { +public class JavaArrayTest { static { System.loadLibrary("JniHelpersTest"); }