Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Java Native Interface
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Performance == JNI incurs considerable overhead and performance loss under certain circumstances:<ref name="StackOverflow: What makes JNI calls slow?">{{cite web|url=https://stackoverflow.com/a/7809300/1068537|title=Java: What makes JNI calls slow? |website=Stack Overflow}}</ref> * Function calls to JNI methods are expensive, especially when calling a method repeatedly. * Native methods are not inlined by the JVM, nor can the method be [[Just-in-time compilation|JIT compiled]], as the method is already compiled. * A Java array may be copied for access in native code, and later copied back. The cost can be linear in the size of the array. * If the method is passed an object, or needs to make a callback, then the native method will likely be making its own calls to the JVM. Accessing Java fields, methods and types from the native code requires something similar to [[reflective programming]] (reflection). Signatures are specified in strings and queried from the JVM. This is both slow and error-prone. * Java Strings are objects, have length and are encoded. Accessing or creating a string may require an O(n) copy.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)