google / jni-bind

JNI Bind is a set of advanced syntactic sugar for writing efficient correct JNI Code in C++17 (and up).
Apache License 2.0
261 stars 31 forks source link

Add multi-dimensional field tests, `ArrayView` lifetime issue. #222

Closed copybara-service[bot] closed 11 months ago

copybara-service[bot] commented 11 months ago

Add multi-dimensional field tests, ArrayView lifetime issue.

Previously, LocalArray would delete itself as it fell out of scope (as designed), but this caused issues for object arrays.

Object arrays are not contiguous so they need to have a living underlying jarray.

This effectively broke iteration on object arrays in fields using the following syntax, because the output of Get would be deleted before the loops completion.

for(LocalArray<jobject, 1, kClass> arr : obj["rank2Field"].Get().Pin()