aboutsummaryrefslogtreecommitdiffstats
path: root/java/jni
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2021-10-05 04:35:41 +0200
committerSven Gothel <[email protected]>2021-10-05 04:35:41 +0200
commite097e56ad4d6db949d8db7ee6d0d1257b5ab0af8 (patch)
tree81c93ef610c1bf70eeaddc0010a973be2190b349 /java/jni
parent4aedaa17b32b76fb6b0ef7b8cc9e703f94f2eb22 (diff)
Adopt to jaulib v0.4.9; Fixes BTSecurityRegistry::getStartOf(..)
Diffstat (limited to 'java/jni')
-rw-r--r--java/jni/direct_bt/DBTDevice.cxx8
-rw-r--r--java/jni/direct_bt/DBTGattChar.cxx8
-rw-r--r--java/jni/direct_bt/DBTGattDesc.cxx4
-rw-r--r--java/jni/helper_base.cxx4
4 files changed, 12 insertions, 12 deletions
diff --git a/java/jni/direct_bt/DBTDevice.cxx b/java/jni/direct_bt/DBTDevice.cxx
index 19a6ef71..3f73c6ad 100644
--- a/java/jni/direct_bt/DBTDevice.cxx
+++ b/java/jni/direct_bt/DBTDevice.cxx
@@ -109,7 +109,7 @@ class JNIGattCharListener : public BTGattCharListener {
JNIEnv *env = *jni_env;
jobject jCharDecl = jau::JavaGlobalObj::GetObject(jCharDeclRef);
- const size_t value_size = charValue.getSize();
+ const size_t value_size = charValue.size();
jbyteArray jval = env->NewByteArray((jsize)value_size);
env->SetByteArrayRegion(jval, 0, (jsize)value_size, (const jbyte *)charValue.get_ptr());
java_exception_check_and_throw(env, E_FILE_LINE);
@@ -130,7 +130,7 @@ class JNIGattCharListener : public BTGattCharListener {
JNIEnv *env = *jni_env;
jobject jCharDecl = jau::JavaGlobalObj::GetObject(jCharDeclRef);
- const size_t value_size = charValue.getSize();
+ const size_t value_size = charValue.size();
jbyteArray jval = env->NewByteArray((jsize)value_size);
env->SetByteArrayRegion(jval, 0, (jsize)value_size, (const jbyte *)charValue.get_ptr());
java_exception_check_and_throw(env, E_FILE_LINE);
@@ -864,8 +864,8 @@ jobject Java_jau_direct_1bt_DBTDevice_getManufacturerData(JNIEnv *env, jobject o
if( nullptr != mdata ) {
result = env->NewObject(map_cls, map_ctor, 1);
- jbyteArray arr = env->NewByteArray(mdata->getData().getSize());
- env->SetByteArrayRegion(arr, 0, mdata->getData().getSize(), (const jbyte *)mdata->getData().get_ptr());
+ jbyteArray arr = env->NewByteArray(mdata->getData().size());
+ env->SetByteArrayRegion(arr, 0, mdata->getData().size(), (const jbyte *)mdata->getData().get_ptr());
jobject key = env->NewObject(short_cls, short_ctor, mdata->getCompany());
env->CallObjectMethod(result, map_put, key, arr);
diff --git a/java/jni/direct_bt/DBTGattChar.cxx b/java/jni/direct_bt/DBTGattChar.cxx
index 1695009b..5b6ab920 100644
--- a/java/jni/direct_bt/DBTGattChar.cxx
+++ b/java/jni/direct_bt/DBTGattChar.cxx
@@ -85,7 +85,7 @@ jobject Java_jau_direct_1bt_DBTGattChar_getDescriptorsImpl(JNIEnv *env, jobject
descriptor->type->toString());
java_exception_check_and_throw(env_, E_FILE_LINE);
- const size_t value_size = descriptor->value.getSize();
+ const size_t value_size = descriptor->value.size();
jbyteArray jval = env_->NewByteArray((jsize)value_size);
env_->SetByteArrayRegion(jval, 0, (jsize)value_size, (const jbyte *)descriptor->value.get_ptr());
java_exception_check_and_throw(env_, E_FILE_LINE);
@@ -114,13 +114,13 @@ jbyteArray Java_jau_direct_1bt_DBTGattChar_readValueImpl(JNIEnv *env, jobject ob
BTGattChar *characteristic = getJavaUplinkObject<BTGattChar>(env, obj);
JavaGlobalObj::check(characteristic->getJavaObject(), E_FILE_LINE);
- POctets res(BTGattHandler::number(BTGattHandler::Defaults::MAX_ATT_MTU), 0);
+ POctets res(BTGattHandler::number(BTGattHandler::Defaults::MAX_ATT_MTU), 0, jau::endian::little);
if( !characteristic->readValue(res) ) {
ERR_PRINT("Characteristic readValue failed: %s", characteristic->toString().c_str());
return env->NewByteArray((jsize)0);
}
- const size_t value_size = res.getSize();
+ const size_t value_size = res.size();
jbyteArray jres = env->NewByteArray((jsize)value_size);
env->SetByteArrayRegion(jres, 0, (jsize)value_size, (const jbyte *)res.get_ptr());
java_exception_check_and_throw(env, E_FILE_LINE);
@@ -149,7 +149,7 @@ jboolean Java_jau_direct_1bt_DBTGattChar_writeValueImpl(JNIEnv *env, jobject obj
if( NULL == value_ptr ) {
throw InternalError("GetPrimitiveArrayCritical(byte array) is null", E_FILE_LINE);
}
- TROOctets value(value_ptr, value_size);
+ TROOctets value(value_ptr, value_size, jau::endian::little);
bool res;
if( withResponse ) {
res = characteristic->writeValue(value);
diff --git a/java/jni/direct_bt/DBTGattDesc.cxx b/java/jni/direct_bt/DBTGattDesc.cxx
index 97b0d3a5..d144aa17 100644
--- a/java/jni/direct_bt/DBTGattDesc.cxx
+++ b/java/jni/direct_bt/DBTGattDesc.cxx
@@ -68,7 +68,7 @@ jbyteArray Java_jau_direct_1bt_DBTGattDesc_readValueImpl(JNIEnv *env, jobject ob
ERR_PRINT("Characteristic readValue failed: %s", descriptor->toString().c_str());
return env->NewByteArray((jsize)0);
}
- const size_t value_size = descriptor->value.getSize();
+ const size_t value_size = descriptor->value.size();
jbyteArray jres = env->NewByteArray((jsize)value_size);
env->SetByteArrayRegion(jres, 0, (jsize)value_size, (const jbyte *)descriptor->value.get_ptr());
java_exception_check_and_throw(env, E_FILE_LINE);
@@ -97,7 +97,7 @@ jboolean Java_jau_direct_1bt_DBTGattDesc_writeValueImpl(JNIEnv *env, jobject obj
if( NULL == value_ptr ) {
throw InternalError("GetPrimitiveArrayCritical(byte array) is null", E_FILE_LINE);
}
- TROOctets value(value_ptr, value_size);
+ TROOctets value(value_ptr, value_size, jau::endian::little);
descriptor->value = value; // copy data
if( !descriptor->writeValue() ) {
diff --git a/java/jni/helper_base.cxx b/java/jni/helper_base.cxx
index 84a6e4c2..c154d65b 100644
--- a/java/jni/helper_base.cxx
+++ b/java/jni/helper_base.cxx
@@ -58,8 +58,6 @@ void rethrow_and_raise_java_exception_impl(JNIEnv *env, const char* file, int li
try {
// std::rethrow_exception(e);
throw; // re-throw current exception
- } catch (const std::bad_alloc &e) {
- jau::raise_java_exception(env, e, file, line);
} catch (const jau::OutOfMemoryError &e) {
jau::raise_java_exception(env, e, file, line);
} catch (const jau::InternalError &e) {
@@ -78,6 +76,8 @@ void rethrow_and_raise_java_exception_impl(JNIEnv *env, const char* file, int li
raise_java_exception(env, e, file, line);
} catch (const jau::RuntimeException &e) {
jau::raise_java_exception(env, e, file, line);
+ } catch (const std::bad_alloc &e) {
+ jau::raise_java_exception(env, e, file, line);
} catch (const std::runtime_error &e) {
jau::raise_java_exception(env, e, file, line);
} catch (const std::invalid_argument &e) {