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!
== Mapping types == The following table shows the mapping of types between Java (JNI) and native code. {| class="wikitable" !C Type !Java Language Type !Description !Type signature |- | {{mono|unsigned char<br/>uint8_t}} | {{mono|jboolean}} |unsigned 8 bits | {{mono|Z}} |- | {{mono|signed char<br/>int8_t}} | {{mono|jbyte}} |signed 8 bits | {{mono|B}} |- | {{mono|unsigned short<br/>uint16_t}} | {{mono|jchar}} |unsigned 16 bits | {{mono|C}} |- | {{mono|short<br/>int16_t}} | {{mono|jshort}} |signed 16 bits | {{mono|S}} |- | {{mono|int<br/>int32_t}} | {{mono|jint}} |signed 32 bits | {{mono|I}} |- | {{mono|long long<br/>int64_t}} | {{mono|jlong}} |signed 64 bits | {{mono|J}} |- | {{mono|float}} | {{mono|jfloat}} |32 bits | {{mono|F}} |- | {{mono|double}} | {{mono|jdouble}} |64 bits | {{mono|D}} |- | {{mono|void}} | | | {{mono|V}} |} In addition, the signature <code>"L {{Sic|hide=y|fully|-}}qualified-class ;"</code> would mean the class uniquely specified by that name; e.g., the signature <code>"Ljava/lang/String;"</code> refers to the class {{Javadoc:SE|package=java.lang|java/lang|String}}. Also, prefixing <code>[</code> to the signature makes the array of that type; for example, <code>[I</code> means the int array type (<code>int[]</code>). Finally, a <code>void</code> signature uses the <code>V</code> code. These types are interchangeable. One can use <code>jint</code> where you normally use an <code>int</code>, and vice versa, without any [[type conversion|typecast]]ing required. However, mapping between Java Strings and arrays to native strings and arrays is different. If a <code>jstring</code> is used where a <code>char *</code> would be, the code could crash the JVM.{{original research inline|date=February 2017}}
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)