Skip to content
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

Add direct and indirect support for arrays. #342

Open
jwhpryor opened this issue Oct 15, 2024 · 0 comments
Open

Add direct and indirect support for arrays. #342

jwhpryor opened this issue Oct 15, 2024 · 0 comments
Assignees
Milestone

Comments

@jwhpryor
Copy link
Collaborator

Arrays of directly spannable types should be able to allocate themselves as direct or indirect (indirect being the default).

I propose the following syntax:

LocalArray<jbyte> direct_array { ArrayDirect{}, 128 };
CHECK(direct_array.IsDirect());

For this to be meaningful, arrays likely need to have a global flavour. Arrays of objects must never be constructible in this manner.

LocalArray<jobject, kClass> direct_array_of_objects {ArrayDirect{}, 10 };  // NO: fails to compile

If an array is allocated directly, the intention is almost certainly to be used for a longer duration than a single native call, so arrays need global support so that the corresponding unlock call can be invoked as the array falls out of scope.

For arrays of objects they will need to have tests added specifically for GlobalArray when it is constructed from a local object.

@jwhpryor jwhpryor added this to the Release 1.1 milestone Oct 15, 2024
@jwhpryor jwhpryor self-assigned this Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant