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

#16 created ForceArrayCritical annotation to prevent copies of array #254

Merged
merged 2 commits into from
Aug 25, 2018

Conversation

vincent-grosbois
Copy link
Contributor

  • When this annotation is added to a method or a class, then all
    wrapper calls will use Get/ReleasePrimitiveArrayCritical pair instead
    of Get/ReleaseArrayElements pair.

@saudet
Copy link
Member

saudet commented Aug 24, 2018 via email

@saudet
Copy link
Member

saudet commented Aug 24, 2018

Also let's make it behave like @NoException, unless you see a good reason not to?

@saudet
Copy link
Member

saudet commented Aug 24, 2018

Hum, there's no test for @NoException, I'm just relying on the presets build to test that at the moment, so let's not worry about a test for the critical one either.

Anyway, as per the JDK's documentation, this function isn't about arrays, it basically stops the JVM:
https://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/functions.html#GetPrimitiveArrayCritical_ReleasePrimitiveArrayCritical
Since this is really about the method itself and not about each argument a name like @CriticalRegion would reflect that better. It will also allow us to use transparently other available JNI functions such as GetStringCritical() and potentially others as they show up for other kinds of objects or for other purposes that also require a stopped JVM.

For this reason, it basically has the same semantics as @NoException, but instead of dealing with C++ exceptions, it enables a critical region in the JVM.

in generated code

* When this annotation is added to a method or a class, then all
wrapper calls will use Get/ReleasePrimitiveArrayCritical pair instead
of Get/Release<primitivetype>ArrayElements pair.
@vincent-grosbois
Copy link
Contributor Author

Hi @saudet
I've updated my commit, hopefully it updates the PR as well.
I made it behave like NoException annotation, so that it will recursively look for the tag in parent classes.
Also renamed the annotation.

@saudet saudet merged commit c50d69f into bytedeco:master Aug 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants