-
Notifications
You must be signed in to change notification settings - Fork 155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
All APIs like env.new_*_array()
should return a JObject
wrapper (like JByteArray
) allowing safe JValue conversion
#396
Comments
Ah, right, I guess this was affected when addressing the soundness issues with allowing safe conversions from sys types: #197 The odd thing here is that We should also track this in the context of #392 where we're looking to ensure that local reference types are non-Copy. Since the array is effectively just an object you can pass your array to method calls like this for now: let buffer = env.new_byte_array(asset_size)?;
let buffer_obj = unsafe { JObject::from_raw(buffer) };
env.call_method(stream, "read", "([B)I", &[buffer_obj.into()])?; We probably shouldn't directly allow safe conversion between What we probably need to do here is introduce a |
env.new_*_array()
should return a JObject
wrapper (like JByteArray
) allowing safe JValue conversion
Hello |
Closes; jni-rs#396 Closes: jni-rs#41
Instead of all the array-based APIs being based on sys types like `jbyteArray` (which can easily lead to the use of invalid local references) this introduces types like `JByteArray<'local>` that have a lifetime parameter to ensure the local reference can't be read if it is deleted or goes out of scope. `JByteArray` and `JIntArray` etc are based on a generic `JPrimitiveArray<T>` which takes any of the primitive types that may be put into arrays, like `jbyte` or `jint`. `JObjectArray` is handled separately, considering that it can't be used with `AutoArray` or `AutoPrimitiveArray`. The implementations of `AutoArray` and `AutoPrimitiveArray` were updated so they can be created based on a `JPrimitiveAarray`. While updating the lifetime parameters to the `AutoArray` and `AutoPrimitiveArray` APIs numerous implementation inconsistencies were found, even though they should only really differ in how they acquire / release the pointer to array elements. This patch also normalizes the implementation of both of these APIs, so they are easily comparable. It may even be possible to unify these at some point. Closes; jni-rs#396 Closes: jni-rs#41
Instead of all the array-based APIs being based on sys types like `jbyteArray` (which can easily lead to the use of invalid local references) this introduces types like `JByteArray<'local>` that have a lifetime parameter to ensure the local reference can't be read if it is deleted or goes out of scope. `JByteArray` and `JIntArray` etc are based on a generic `JPrimitiveArray<T>` which takes any of the primitive types that may be put into arrays, like `jbyte` or `jint`. `JObjectArray` is handled separately, considering that it can't be used with `AutoArray` or `AutoPrimitiveArray`. The implementations of `AutoArray` and `AutoPrimitiveArray` were updated so they can be created based on a `JPrimitiveAarray`. While updating the lifetime parameters to the `AutoArray` and `AutoPrimitiveArray` APIs numerous implementation inconsistencies were found, even though they should only really differ in how they acquire / release the pointer to array elements. This patch also normalizes the implementation of both of these APIs, so they are easily comparable. It may even be possible to unify these at some point. Closes; jni-rs#396 Closes: jni-rs#41
Instead of all the array-based APIs being based on sys types like `jbyteArray` (which can easily lead to the use of invalid local references) this introduces types like `JByteArray<'local>` that have a lifetime parameter to ensure the local reference can't be read if it is deleted or goes out of scope. `JByteArray` and `JIntArray` etc are based on a generic `JPrimitiveArray<T>` which takes any of the primitive types that may be put into arrays, like `jbyte` or `jint`. Since types like `JByteArray` are simply aliases for `JPrimitiveArray<T>` there's no need to keep separate `JNIEnv::get_<type>_array_elements` methods since they can all be passed to `JNIEnv::get_array_elements`. `JObjectArray` is handled separately, considering that it can't be used with `AutoArray` or `AutoPrimitiveArray`. The implementations of `AutoArray` and `AutoPrimitiveArray` were updated so they can be created based on a `JPrimitiveAarray`. While updating the lifetime parameters to the `AutoArray` and `AutoPrimitiveArray` APIs numerous implementation inconsistencies were found, even though they should only really differ in how they acquire / release the pointer to array elements. This patch also normalizes the implementation of both of these APIs, so they are easily comparable. It may even be possible to unify these at some point. For now the `test_get_array_elements` tests have been kept at least for the sake of checking the data integrity from updating array elements of different types/sizes, even though they now utilize the same `get_array_elements` code. Closes; jni-rs#396 Closes: jni-rs#41
Instead of all the array-based APIs being based on sys types like `jbyteArray` (which can easily lead to the use of invalid local references) this introduces types like `JByteArray<'local>` that have a lifetime parameter to ensure the local reference can't be read if it is deleted or goes out of scope. `JByteArray` and `JIntArray` etc are based on a generic `JPrimitiveArray<T>` which takes any of the primitive types that may be put into arrays, like `jbyte` or `jint`. Since types like `JByteArray` are simply aliases for `JPrimitiveArray<T>` there's no need to keep separate `JNIEnv::get_<type>_array_elements` methods since they can all be passed to `JNIEnv::get_array_elements`. `JObjectArray` is handled separately, considering that it can't be used with `AutoArray` or `AutoPrimitiveArray`. The implementations of `AutoArray` and `AutoPrimitiveArray` were updated so they can be created based on a `JPrimitiveAarray`. While updating the lifetime parameters to the `AutoArray` and `AutoPrimitiveArray` APIs numerous implementation inconsistencies were found, even though they should only really differ in how they acquire / release the pointer to array elements. This patch also normalizes the implementation of both of these APIs, so they are easily comparable. It may even be possible to unify these at some point. For now the `test_get_array_elements` tests have been kept at least for the sake of checking the data integrity from updating array elements of different types/sizes, even though they now utilize the same `get_array_elements` code. Closes; jni-rs#396 Closes: jni-rs#41
Instead of all the array-based APIs being based on sys types like `jbyteArray` (which can easily lead to the use of invalid local references) this introduces types like `JByteArray<'local>` that have a lifetime parameter to ensure the local reference can't be read if it is deleted or goes out of scope. `JByteArray` and `JIntArray` etc are based on a generic `JPrimitiveArray<T>` which takes any of the primitive types that may be put into arrays, like `jbyte` or `jint`. Since types like `JByteArray` are simply aliases for `JPrimitiveArray<T>` there's no need to keep separate `JNIEnv::get_<type>_array_elements` methods since they can all be passed to `JNIEnv::get_array_elements`. `JObjectArray` is handled separately, considering that it can't be used with `AutoArray` or `AutoPrimitiveArray`. The implementations of `AutoArray` and `AutoPrimitiveArray` were updated so they can be created based on a `JPrimitiveAarray`. While updating the lifetime parameters to the `AutoArray` and `AutoPrimitiveArray` APIs numerous implementation inconsistencies were found, even though they should only really differ in how they acquire / release the pointer to array elements. This patch also normalizes the implementation of both of these APIs, so they are easily comparable. It may even be possible to unify these at some point. For now the `test_get_array_elements` tests have been kept at least for the sake of checking the data integrity from updating array elements of different types/sizes, even though they now utilize the same `get_array_elements` code. Closes; jni-rs#396 Closes: jni-rs#41
Instead of all the array-based APIs being based on sys types like `jbyteArray` (which can easily lead to the use of invalid local references) this introduces types like `JByteArray<'local>` that have a lifetime parameter to ensure the local reference can't be read if it is deleted or goes out of scope. `JByteArray` and `JIntArray` etc are based on a generic `JPrimitiveArray<T>` which takes any of the primitive types that may be put into arrays, like `jbyte` or `jint`. Since types like `JByteArray` are simply aliases for `JPrimitiveArray<T>` there's no need to keep separate `JNIEnv::get_<type>_array_elements` methods since they can all be passed to `JNIEnv::get_array_elements`. `JObjectArray` is handled separately, considering that it can't be used with `AutoArray` or `AutoPrimitiveArray`. The implementations of `AutoArray` and `AutoPrimitiveArray` were updated so they can be created based on a `JPrimitiveAarray`. While updating the lifetime parameters to the `AutoArray` and `AutoPrimitiveArray` APIs numerous implementation inconsistencies were found, even though they should only really differ in how they acquire / release the pointer to array elements. This patch also normalizes the implementation of both of these APIs, so they are easily comparable. It may even be possible to unify these at some point. For now the `test_get_array_elements` tests have been kept at least for the sake of checking the data integrity from updating array elements of different types/sizes, even though they now utilize the same `get_array_elements` code. Closes; jni-rs#396 Closes: jni-rs#41
Instead of all the array-based APIs being based on sys types like `jbyteArray` (which can easily lead to the use of invalid local references) this introduces types like `JByteArray<'local>` that have a lifetime parameter to ensure the local reference can't be read if it is deleted or goes out of scope. `JByteArray` and `JIntArray` etc are based on a generic `JPrimitiveArray<T>` which takes any of the primitive types that may be put into arrays, like `jbyte` or `jint`. Since types like `JByteArray` are simply aliases for `JPrimitiveArray<T>` there's no need to keep separate `JNIEnv::get_<type>_array_elements` methods since they can all be passed to `JNIEnv::get_array_elements`. `JObjectArray` is handled separately, considering that it can't be used with `AutoArray` or `AutoPrimitiveArray`. The implementations of `AutoArray` and `AutoPrimitiveArray` were updated so they can be created based on a `JPrimitiveAarray`. While updating the lifetime parameters to the `AutoArray` and `AutoPrimitiveArray` APIs numerous implementation inconsistencies were found, even though they should only really differ in how they acquire / release the pointer to array elements. This patch also normalizes the implementation of both of these APIs, so they are easily comparable. It may even be possible to unify these at some point. For now the `test_get_array_elements` tests have been kept at least for the sake of checking the data integrity from updating array elements of different types/sizes, even though they now utilize the same `get_array_elements` code. Closes; jni-rs#396 Closes: jni-rs#41
Instead of all the array-based APIs being based on sys types like `jbyteArray` (which can easily lead to the use of invalid local references) this introduces types like `JByteArray<'local>` that have a lifetime parameter to ensure the local reference can't be read if it is deleted or goes out of scope. `JByteArray` and `JIntArray` etc are based on a generic `JPrimitiveArray<T>` which takes any of the primitive types that may be put into arrays, like `jbyte` or `jint`. Since types like `JByteArray` are simply aliases for `JPrimitiveArray<T>` there's no need to keep separate `JNIEnv::get_<type>_array_elements` methods since they can all be passed to `JNIEnv::get_array_elements`. `JObjectArray` is handled separately, considering that it can't be used with `AutoArray` or `AutoPrimitiveArray`. The implementations of `AutoArray` and `AutoPrimitiveArray` were updated so they can be created based on a `JPrimitiveAarray`. While updating the lifetime parameters to the `AutoArray` and `AutoPrimitiveArray` APIs numerous implementation inconsistencies were found, even though they should only really differ in how they acquire / release the pointer to array elements. This patch also normalizes the implementation of both of these APIs, so they are easily comparable. It may even be possible to unify these at some point. For now the `test_get_array_elements` tests have been kept at least for the sake of checking the data integrity from updating array elements of different types/sizes, even though they now utilize the same `get_array_elements` code. Closes; jni-rs#396 Closes: jni-rs#41
Instead of all the array-based APIs being based on sys types like `jbyteArray` (which can easily lead to the use of invalid local references) this introduces types like `JByteArray<'local>` that have a lifetime parameter to ensure the local reference can't be read if it is deleted or goes out of scope. `JByteArray` and `JIntArray` etc are based on a generic `JPrimitiveArray<T>` which takes any of the primitive types that may be put into arrays, like `jbyte` or `jint`. Since types like `JByteArray` are simply aliases for `JPrimitiveArray<T>` there's no need to keep separate `JNIEnv::get_<type>_array_elements` methods since they can all be passed to `JNIEnv::get_array_elements`. `JObjectArray` is handled separately, considering that it can't be used with `AutoArray` or `AutoPrimitiveArray`. The implementations of `AutoArray` and `AutoPrimitiveArray` were updated so they can be created based on a `JPrimitiveAarray`. While updating the lifetime parameters to the `AutoArray` and `AutoPrimitiveArray` APIs numerous implementation inconsistencies were found, even though they should only really differ in how they acquire / release the pointer to array elements. This patch also normalizes the implementation of both of these APIs, so they are easily comparable. It may even be possible to unify these at some point. For now the `test_get_array_elements` tests have been kept at least for the sake of checking the data integrity from updating array elements of different types/sizes, even though they now utilize the same `get_array_elements` code. Closes; jni-rs#396 Closes: jni-rs#41
Instead of all the array-based APIs being based on sys types like `jbyteArray` (which can easily lead to the use of invalid local references) this introduces types like `JByteArray<'local>` that have a lifetime parameter to ensure the local reference can't be read if it is deleted or goes out of scope. `JByteArray` and `JIntArray` etc are based on a generic `JPrimitiveArray<T>` which takes any of the primitive types that may be put into arrays, like `jbyte` or `jint`. Since types like `JByteArray` are simply aliases for `JPrimitiveArray<T>` there's no need to keep separate `JNIEnv::get_<type>_array_elements` methods since they can all be passed to `JNIEnv::get_array_elements`. `JObjectArray` is handled separately, considering that it can't be used with `AutoArray` or `AutoPrimitiveArray`. The implementations of `AutoArray` and `AutoPrimitiveArray` were updated so they can be created based on a `JPrimitiveAarray`. While updating the lifetime parameters to the `AutoArray` and `AutoPrimitiveArray` APIs numerous implementation inconsistencies were found, even though they should only really differ in how they acquire / release the pointer to array elements. This patch also normalizes the implementation of both of these APIs, so they are easily comparable. It may even be possible to unify these at some point. For now the `test_get_array_elements` tests have been kept at least for the sake of checking the data integrity from updating array elements of different types/sizes, even though they now utilize the same `get_array_elements` code. Closes; jni-rs#396 Closes: jni-rs#41
Instead of all the array-based APIs being based on sys types like `jbyteArray` (which can easily lead to the use of invalid local references) this introduces types like `JByteArray<'local>` that have a lifetime parameter to ensure the local reference can't be read if it is deleted or goes out of scope. `JByteArray` and `JIntArray` etc are based on a generic `JPrimitiveArray<T>` which takes any of the primitive types that may be put into arrays, like `jbyte` or `jint`. Since types like `JByteArray` are simply aliases for `JPrimitiveArray<T>` there's no need to keep separate `JNIEnv::get_<type>_array_elements` methods since they can all be passed to `JNIEnv::get_array_elements`. `JObjectArray` is handled separately, considering that it can't be used with `AutoArray` or `AutoPrimitiveArray`. The implementations of `AutoArray` and `AutoPrimitiveArray` were updated so they can be created based on a `JPrimitiveAarray`. While updating the lifetime parameters to the `AutoArray` and `AutoPrimitiveArray` APIs numerous implementation inconsistencies were found, even though they should only really differ in how they acquire / release the pointer to array elements. This patch also normalizes the implementation of both of these APIs, so they are easily comparable. It may even be possible to unify these at some point. For now the `test_get_array_elements` tests have been kept at least for the sake of checking the data integrity from updating array elements of different types/sizes, even though they now utilize the same `get_array_elements` code. Closes; jni-rs#396 Closes: jni-rs#41
Instead of all the array-based APIs being based on sys types like `jbyteArray` (which can easily lead to the use of invalid local references) this introduces types like `JByteArray<'local>` that have a lifetime parameter to ensure the local reference can't be read if it is deleted or goes out of scope. `JByteArray` and `JIntArray` etc are based on a generic `JPrimitiveArray<T>` which takes any of the primitive types that may be put into arrays, like `jbyte` or `jint`. Since types like `JByteArray` are simply aliases for `JPrimitiveArray<T>` there's no need to keep separate `JNIEnv::get_<type>_array_elements` methods since they can all be passed to `JNIEnv::get_array_elements`. `JObjectArray` is handled separately, considering that it can't be used with `AutoArray` or `AutoPrimitiveArray`. The implementations of `AutoArray` and `AutoPrimitiveArray` were updated so they can be created based on a `JPrimitiveAarray`. While updating the lifetime parameters to the `AutoArray` and `AutoPrimitiveArray` APIs numerous implementation inconsistencies were found, even though they should only really differ in how they acquire / release the pointer to array elements. This patch also normalizes the implementation of both of these APIs, so they are easily comparable. It may even be possible to unify these at some point. For now the `test_get_array_elements` tests have been kept at least for the sake of checking the data integrity from updating array elements of different types/sizes, even though they now utilize the same `get_array_elements` code. Closes; jni-rs#396 Closes: jni-rs#41
Particulary to be able to call a methode with a byte array in parameter.
It was possible in JNI 0.19 thanks to
into
but the new conversion methode doesn't work with jbyteArray.e.g:
jni-rs 0.19
The text was updated successfully, but these errors were encountered: