Click here to Skip to main content
15,886,806 members
Everything / JNI

JNI

JNI

Great Reads

by Android on Intel
This blog outlines the steps needed to integrate Intel’s AES-NI instructions into an Android app via the OpenSSL library.
by Android on Intel
This document is focused on creating OpenCV-enabled applications for Android. If the target operating system of your application is Windows
by Android on Intel
In this paper, we introduce some of the new features in ART, benchmark it against the previous Android Dalvik* runtime, and share five tips for developers that can further improve application performance.
by Android on Intel
This article walks through an example Android application that offloads image processing using OpenCL™ and RenderScript programming languages.

Latest Articles

by Yochai Timmer
A way to avoid JNI's reflection oriented programming. Wrapping Java with C++
by mohamadArdestani
get shutdown message in java application with jni
by YevheniyK
The article describes a general approach to using Cocos2d-x on top of native components and relevant coding specifics for Cocos2d-x, iOS and Android.
by Luca Basso Ricci
How to build the JNI signature for a Java method

All Articles

Sort by Score

JNI 

6 Aug 2012 by Volynsky Alex
Hi Sergey,You can see the SWIG (Simplified Wrapper and Interface Generator):http://www.swig.org/tutorial.html[^]http://www.swig.org/Doc2.0/SWIGDocumentation.html[^]I hope this will help you
9 May 2021 by Richard MacCutchan
I do not know where you found that code but the official documentation is different: The Invocation API[^]. Also why do you write: mbstowcs(t, "C:\\Program Files (x86)\\Java\\jdk-16.0.1\\jre\\bin\\server\\jvm.dll", 400); jvm_dll =...
3 Feb 2011 by Manfred Rudolf Bihy
JNI is javas native interface and was meant to integrate system specific processes with the java world. Since programs\libraries that are used on one OS can't be directly used on another OS, I would say that you would have to port the library/program from windows to whatever OS you're planning...
31 Jul 2011 by Espen Harlinn
You'll find the JNI code here:SWT: The Standard Widget Toolkit[^]I know SWT is not Swing - but SWT has the required JNI code.Remember that Swing is built on top of the original objects and framework of AWT.Inside the $(JDK)\include folder you'll find jawt.hInside the...
6 Aug 2012 by Sergey Vystoropskiy
Also I hade found this one http://code.google.com/p/android-cpp-sdk/[^]
3 Oct 2011 by Richard MacCutchan
See here[^] to check your code is following the correct rules. Also, make sure you have defined your JNI calls within extern "C" {} blocks, to prevent name mangling by the compiler.
4 Oct 2011 by Richard MacCutchan
I don't know why this happens BUT:In your C code, if you replace the line:res = JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args);with// this should contain the path to the JVM DLL fileHINSTANCE hVM = LoadLibrary("C:\\Program Files (x86)\\Java\\jre6\\bin\\client\\jvm.dll");if (hVM...
5 Oct 2011 by Espen Harlinn
It's customary to locate the java runtime trough settings from the registry, and then load the dll dynamically.Have look at:Jace[^]Jace offers some additional features you might find interesting too.[Update]The _imp__ prefix indicates that you have a problem with your library - I...
24 Sep 2012 by pasztorpisti
What about checking out and modifying existing code? How to Call Java Functions from C Using JNI[^]
19 Feb 2013 by Leo Chapiro
You have to link with JVM's library (add some reference to libjvm.a to the tcc's command line).If you don't have a precompiled jvm.lib file for TurboC++, there is another option - link with the jvm.dll file and export all the methods from JVM manually. This uses the...
1 Aug 2010 by Anoop SL
Dear Coders,I'm implementing a browser based application which accesses some native c++ calls runtime. I'm using Http at browser and calling my native c++ using java script and JNI. So far I'm successful to some degree only with safari browser. Can somebody enlighten me on why this is...
2 Nov 2010 by Nagy Vilmos
The JVM used inside a browser are 'sandboxed'. They have restricted access outside of the browser to prevent malicious code damaging the client machine.If you are [still] experiencing problems with calling your external processes, I would recommend checking the requirements for supporting...
23 Nov 2010 by lpbolg
//this's jni function in dll;JNIEXPORT jstring JNICALL Java_vc_CallVc_getActiveWindowTitle//get title(JNIEnv * jn, jclass){ jstring str; const char *strTitle =GetStringUTFChars( str , 0); ...
23 Nov 2010 by Aescleal
If you post (a) the Java you're using and (b) what the error is people might be able to help a bit more.I don't know anything about JNI but have you considered that in the second lump of code you're using an uninitialised variable?In the first lump you also cast a const pointer to a...
9 Jan 2011 by Saw Thanda Oo
How to Convert jstring to Java.Lang.String and Java.Lang.String to jstring.
9 Jan 2011 by CPallini
You need to perform no conversion: JNI makes the Java's String class content available to native functions as jstring type. Have a look at the following documentation page for detailed info Basic Types, Strings and Arrays[^].:-)
2 Feb 2011 by Reza Oruji
Hi,I have written a Java program that uses jni in windows.Now I want to know, if this program is portable and if I can run it in another OS?
12 Jul 2011 by saideh86
Hi every one.I have read a document from nist website (http://csrc.nist.gov/groups/ST/toolkit/rng/documentation_software.html) in this document said that" With minor modifications, source code may be ported to different platforms. The NIST source code was ported to a Windows XP system running...
13 Jul 2011 by Albert Holguin
Look at the libraries specified in the linker options of the functioning code and make sure that all those are also specified in the linker options of the code giving you the errors. Like Richard mentioned, this looks like you're missing .libs.
30 Jul 2011 by Himanshu Bajpai
I am new to java .I add one extra menu on system menu now I want to handle an event on the system menu in java swings application i prepare a dll for that in c++ and i am unable to handle the event on system menu through dll using wndproc method through JNI if there any one who helps me to do this.
31 Jul 2011 by Richard MacCutchan
I don't think you can do this, all events will be handled by the JVM so your wndproc procedure will not get called. Espen has given a great explanation of this.
3 Aug 2011 by Himanshu Bajpai
sir I have added one own menu item in window menu using jni,vc++,java. sir I want to handle event on that item using jni.how it can be possible. sir this can be done by jinvoke package in java.This package contain user32 class.so it can be done by jinvoke package. But sir I can't use this...
4 Oct 2011 by anktrive
Hi, I am new to JNI and I have been trying to write a simple program to call Java code from C++. I am facing problem in creating the JavaVM from C and am getting the Linker error. I have tried changing the GNU library files in dev C++ (I am using Dev c++ compiler) but no luck so far....
5 Oct 2011 by Richard MacCutchan
My apologies but I was compiling as C++, which does not work for standard C. Modify the code between the lines #ifdef JNI_VERSION_1_2 and #else as follows:#ifdef JNI_VERSION_1_2// definitions required to get the proc address HINSTANCE hVM; typedef jint (CALLBACK *fpCJV)(JavaVM**,...
28 Apr 2012 by Thenraja
I googled and got some answers that communication between Java and Haskell can be done by GCJNI(Now the site is down) and LambdaVM.. To use the LambdaVM/GCJNI, whether I need to download any build tools? Where can I know more about them, since I don't find much resources on online?I want to...
28 Apr 2012 by Mehdi Gholam
Take a look here :http://www.haskell.org/haskellwiki/Applications_and_libraries/Interfacing_other_languages#Java[^]You could create a webservice also :http://stackoverflow.com/questions/6663888/web-service-frameworks-in-haskell[^]
16 May 2012 by Anil Kumar 23
HiI m trying to create a header file for a sample helloworld program calling a native funtion from native dll to be made with the help of this header file.I have compiled the java file but now when i m creating the header file m getting an error...error: cannot access HelloWorldclass...
27 Jun 2012 by the vacuum
We have developed a dll which contains APIs to take camera snap using DirectShow( windows). It uses COM(component object model) for accessing directshow API's and its working fine using in VS2008 MFC application. Then we created JNI wrapper functions to call above dll functions from Java. But...
18 Jul 2012 by subrata kumar Nayak
I have created an app in android using JNI(as major part of my code is in C). Now i am having a requirement to parse xml in my application.As I have chosen libxml2 for my application, can any one please tell me how to use libxml2 in my android application ?
23 Jul 2012 by subrata kumar Nayak
just add the line LOCAL_EXPORT_C_INCLUDES := pathto/folder (where my file resides) above theinclude $(PREBUILT_STATIC_LIBRARY)and my final .mk file became like this:LOCAL_PATH := $(call my-dir)include $(CLEAR_VARS)LOCAL_MODULE := libtestLOCAL_SRC_FILES :=...
22 Jul 2012 by subrata kumar Nayak
since there is no prebuilt libxml.so/.a file for libxml parser, so we need to create the library (either .so/.a) and use that in ur application u have to download all the .c/.h/android.mk/Application.mk and just build the libxml library(either .so/.a)
23 Jul 2012 by subrata kumar Nayak
it was a silly thing...replace ' with \\' ,not with\'....thn rest are same as it was...
2 Aug 2012 by subrata kumar Nayak
i am creating an application in android using ndk and jni.In my app i have requirement to parse xml data.for which i have used libxml2.when i am making a static library of libxml2 and use,it works fine.But when i am trying to make a shared library and use it in my application i am...
6 Aug 2012 by Sergey Vystoropskiy
I want to start a small project on C++ for android. I don't like that ugly c-style JNI. Is there some good C++ wrappers ?
6 Aug 2012 by Sergey Alexandrovich Kryukov
Did you try this one:http://www.teamdev.com/jniwrapper/[^],http://www.teamdev.com/jniwrapper/documentation/[^]?By documentation, it looks good, but unfortunately, it's commercial. And I never tried it.—SA
8 Aug 2012 by subrata kumar Nayak
since u want to create a A.dll and call B.dll from A.dll, so i would recommend u to jst create the B.lib and put it inside A.dll then u will be able to call the functions of both class A&B hope this will work........All the best.......
11 Sep 2012 by AhmdAxf
for the System.loadLibrary() call the dll file should be in path of java i.e system32 but i would recommend System.load() instead by which you would be able to give full path of the dll file and use it in any other java app usin that jar
3 Dec 2012 by Manish_Mohan
Hi all,Does anyone know how to resolve this exception.## A fatal error has been detected by the Java Runtime Environment:## EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6d7a83f0, pid=6320, tid=6328## JRE version: 7.0_05-b05# Java VM: Java HotSpot(TM) Client VM (23.1-b03...
19 Feb 2013 by Moorthy Rajendran
JNI_CreateJavaVM(&jvm, (void **)&env, &args);tcc C:\TurboC++\Disk\TurboC3\BIN\CTest.c -I "C:\Program Files\Java\jdk1.6.0_16\include" -I "C:\Program Files\Java\jdk1.6.0_16\include\win32" -I "C:\Program Files\Java\jdk1.6.0_16\lib" -shared -o CTest.dllError: tcc: undefined symbol...
20 Aug 2013 by Buddhi Chaturanga
I constructed a java program using netbeans IDE that has ability to connect with a respective DLL; I want to connect and interchange data between my java program(.jar) and VSC++ program(.exe) through DLLs.JNI uses single Dll to invoke C/C++ function in native manner,In order to increase the...
22 Oct 2013 by Member 10286395
he code below gives me all elements of any window but i want to know the particular button/link/textbox accessed by user ...User32.INSTANCE.EnumChildWindows(GetForegroundWindow(), new User32.WNDENUMPROC() { int count = 1; ...
13 Dec 2013 by manish yadav
I am using http://www.sqlite.org/c3ref/open.html as a reference for using the sqlite c for opening the dbi m calling like this package com.example.offline; public class NativeLib { static { System.loadLibrary("sqlite3"); } ...
3 Jun 2014 by E.F. Nijboer
Git is a distributed version control system and github is an online location for sharing repositories. You cannot debug it directly. You need to download it or use:git clone --bare https://github.com/FreeRDP/FreeRDP.gitOf course you must have git installed. Download link:...
16 Jul 2014 by Member 10378849
I search for solution 3 day still I cant find.My java file work normally and no error. I copied my java file "I2CInterface.java" to "jdk/bin" directory. Then "javac I2CInterface.java" the I2CInterface.class created succesfully. But "javah -jni I2CInterface" give error class couldnt found....
12 Feb 2015 by Android on Intel
This blog outlines the steps needed to integrate Intel’s AES-NI instructions into an Android app via the OpenSSL library.
19 Mar 2015 by rahul15001
I have a int array like int[][] arrays = { array1, array2, array3, array4, array5 };where array1=30,40,20,40 ,array2=40,20,30,30 and I am trying to send this array to C with using JNI. I could not find any clear solution for this. I have tried to take this int as a intarray but no success.Is...
20 Mar 2015 by KarstenK
I found this fine Java Programming Tutorial for JNI with example for int array.Very important is to release all memory carefully or the jni gets into trouble without any clear errors.
21 Mar 2015 by rahul15001
I have a int array likeint[][] coordinates = {{346, 640, 499, 666},{555, 640, 675, 666}};and I am trying to send this array to C with using JNI. I could find clear solution for one dimensional array but not for multidimensional array.public class PopulateCoordinates{public native...
21 Mar 2015 by KarstenK
To be honest: The simplest and savest way is to use one dimension arrays with native data types and AVOID structs. Java and C have different memory layouts. Microsoft has solved this mess on its .net-languages.I would extend the interfaces of rhe func with size information:JNIEXPORT...
22 Mar 2015 by rahul15001
I have a string array like {"myname","yourname","hisname"} and I am trying to send this array to C with using JNI. I could not find any clear solution for this. I have tried to take this string as a chararray but no success.Is there a way to do this?
22 Mar 2015 by Richard MacCutchan
It is not really clear what the issue is, but I suggest you take a look at https://docs.oracle.com/javase/7/docs/technotes/guides/jni/spec/jniTOC.html[^], which explains how to pass different types between Java and C/C++.
21 Jun 2015 by saudi-knight
So this is the error I get on Eclipse:## A fatal error has been detected by the Java Runtime Environment:## Internal Error (0xe0434352), pid=7696, tid=8632## JRE version: Java(TM) SE Runtime Environment (8.0_45-b15) (build 1.8.0_45-b15)# Java VM: Java HotSpot(TM) Client VM...
6 Jul 2015 by Android on Intel
This document is focused on creating OpenCV-enabled applications for Android. If the target operating system of your application is Windows
20 Jul 2015 by Android on Intel
In this paper, we introduce some of the new features in ART, benchmark it against the previous Android Dalvik* runtime, and share five tips for developers that can further improve application performance.
28 Aug 2015 by RupeshMote
I want to access c++ code from java program. For that I used concept of JNI.I declare one native method in java, whose return type is Mat class of opencv, as follows :public native Mat getFrames();Then using javah utility, I created c implementation(Header File) of my java class...
28 Aug 2015 by CPallini
See this Stack Overflow question: "Returning Mat object from native code to java in OpenCV"[^].
1 Oct 2015 by Android on Intel
This article walks through an example Android application that offloads image processing using OpenCL™ and RenderScript programming languages.
10 Nov 2015 by mayooran99
I have the a JNA structure which is throwing InvalidMemoryAccessException occasionally. Without changing the code,when I run it, it runs at times. At times it throw the exception as shown below.Exception in thread "main" java.lang.Error: Invalid memory accessat...
11 Nov 2015 by W Balboos, GHB
The reason for the 'sometimes'   is that a pointer, du to the un-initialized pointer (null pointer) is likely being over-written with varying data.   It's value typically changes with each execution of your application.   Depending upon where it's pointing will depend upon if, or more likely,...
18 Sep 2016 by Member 12373848
I am trying to write DVD RW / CD using IMAPI 2.0 with C++. The created dll is being called from a Java Application.I am getting a crash in code which is the following :## A fatal error has been detected by the Java Runtime Environment:## EXCEPTION_ACCESS_VIOLATION (0xc0000005) at...
18 Sep 2016 by Patrice T
Even with best will, it is not possible to help you with this.You should read thisAsking questions is a skill[^]
19 Sep 2016 by Tejas Sawant 13
Question is very simple I need alternate code for below line IntPtr i =Marshal.StringToHGlobalAnsi("Hello World");I am struggling a lot for same please help me.What I have tried:From 2 days trying every possible solution. But no output.
19 Sep 2016 by Richard MacCutchan
No you have not tried every possible solution, because I told you yesterday in http://www.codeproject.com/Questions/1130172/Csharp-code-to-JAVA-code[^] what you need to do. So now you need to go back and do it. The only way to interface between Java and a C/C++ dll is by using the JNI. And you...
26 Oct 2016 by Member 12373848
I am creating a dll using IMAPI 2.0 with C++, can anyone help in how to monitor progress of burn & conitinuously send updates from dll to Java.What I have tried:I was trying to attach IDiscFormat2Data Event to burn thread. But how send this update continuosly to Java.
26 Oct 2016 by Member 12373848
How to call a MFC dll from Java. So that it feels as if Java launched the MFC UI.I am developing a MFC dll using IMAPI 2.0 with C++ to burn data on DVD/CD. I want to call this dll from Java & hence the run MFC dll with its UI. This will help in monitoring the burn process.What I have...
26 Oct 2016 by KarstenK
You must correct initialize the MFC runtime before the first use, like it is here described.For updating the UI you must implement an interface function with JNI to the MFC-dll, in which the update (as message parameter) the signaled. Because the JRE/JNI and the MFC are in different...
26 Oct 2016 by KarstenK
The easiest way is to setup a timer in java and poll for the actual status in C++. It makes a lot sense to poll "only once" in a second.
26 Oct 2016 by Richard MacCutchan
See jni mfc - Google Search[^].Also, you already posted this question at How to monitor progress of burn using IMAPI 2.0 and pass updates to java[^]. Please do not repost.
1 Nov 2016 by Member 12373848
I am developing a JavaFX application & a C++ dll whose method i want to call from JavaFX (java code). So, i have placed the dll in project directory, getting the working directory during runtime , hence creating the path to dll , setting the same path value to "java.library.path" & then loading...
31 Oct 2016 by KarstenK
The called function isnt properly exported with JNI from your C dll, maybe it is only the wrong data type as parameters. The first is ALWAYS the JNI pointer. Here is a fine looking tutorial where all is explained.JNI works that way, so take care to implement the c-dll in this manner.
12 Apr 2017 by Nick_3141592654
It's not possible to use C++ without JNI - the point is that JNI *IS* native code, i.e. the very fact that you want to use C++ (or C) means that you are using a native library, within a Java environment => JNI. Remember that you only need to provide the JNI wrapper code for your API between the...
23 Apr 2017 by amir tarek
i make a simple c function in Visual studio 6 this is the code #include "stdafx.h" BOOL APIENTRY DllMain( HANDLE hModule,DWORD ul_reason_for_call,LPVOID lpReserved) { return TRUE; } extern "C" __declspec(dllexport) char __stdcall GetCompanyCode() { return 1; } i need to call the...
23 Apr 2017 by KarstenK
You must carefully read and understand the error message. Here is "Error looking up function 'GetCompanyCode': The specified procedure could not be found." So the linker says that dll is found but the function not. Check with the good olddepedency walker that the function name is properly...
9 Apr 2018 by ShrinidhiN
I need to reference a .Net COM dll in java. I have used jni4net libraries for the same. I have followed the steps mentioned in the video below : https://www.youtube.com/watch?time_continue=351&v=8OoSK_RWUe4 I have followed all the steps required to reference jni4net libraries but i get the...
12 Jun 2018 by Manish Sharma
I need to call some Java methods using C/C++ and then I need to use DPI in UVM or system verilog to call C methods. I dont have access for JAVA files or JAVA classes. I have a .jar file in which my class is present of which methods I need to access. I am using path of that .jar file in ...
12 Jun 2018 by KarstenK
Normally JNI works and you have missed some details. Read the article Calling Java from C++ with JNI in which the JNI is used as I had been working with it. Check that the packages, classes and functions are public. At last you can try to do your work in Java and only export the results as...
9 Aug 2019 by Srikanth Chadalavada
I am having an issue with windows closeHandle((Handle)port) function in our .dll. it is not returning. The issue happens every few hours. The java application using the .dll connects, reads and writes data. The last method call java application does is to write the data and release method is...
9 Aug 2019 by KarstenK
If you write on the port you should check that the data is written and than close the port. It is best to open only when needed and than close again. Read about the specific timeouts of that port. Be precise about not opened multiple ports or double close ports, this can lead to strange...
6 May 2021 by Richard MacCutchan
This is effectively the same question as Access a C structure array from java using JNI[^]. Please do not repost.
6 May 2021 by OriginalGriff
Repost: deleted. This is the same question you asked an hour ago: Access a C structure array from java using JNI[^]
6 May 2021 by Member 15076657
I want to access my c code from java and get data from C struct using JNI. I want to achieve this using hashtable or hashmap. Here is my C struct: struct process { char str[]; char strr[]; int i; }; struct process *ptr; Now, I want to pass the...
6 May 2021 by KarstenK
Be happy that it works and move on. Transfering complex objects between different runtimes isnt possible because of memory layout. You may transfer some byte array in which the data is an reinterpret it. Like struct Data { int i; int lenstr; ...
6 May 2021 by Richard MacCutchan
Quote: Can I pass the data using Hashtable or Hashmap? Or can I pass the struct array directly to java? Is there any decent way for doing this? Sadly, no. The Java Native Interface is designed to allow C programmers to write support libraries...
9 May 2021 by Member 15076657
I am using this as a reference to call my java class inside C program. But , JVM is not launching. Here is my code for launching jvm.
10 May 2021 by Member 15076657
I'm trying to run an .exe. When it runs, it shows the following error. Error occurred during initialization of VM Unable to load native library: Can't find dependent libraries What does this mean? JNIEnv* create_vm(JavaVM** jvm) { //JavaVM*...
9 May 2021 by OriginalGriff
If you don't understand an error message, Google it: Error occurred during initialization of VM Unable to load native library: Can't find dependent libraries - Google Search[^] What it means is that a DLL is missing, or incompatible with the...
10 May 2021 by Richard MacCutchan
OK, I have a working version, which required a couple of minor changes: #include JNIEnv* create_vm(JavaVM** jvm) { //JavaVM* jvm; /* denotes a Java VM */ JNIEnv* env; /* pointer to native method interface */ JavaVMInitArgs...
12 May 2021 by 15160877
I want to send an empty hashmap from java to C. After that, I need to store data from C to hashmap and again pass it to java. I can now access my java functions from C. But, now I want to pass a hashmap from java and store the data and pass the...
12 May 2021 by Richard MacCutchan
You have to start again from the other side. You need to create a C library with a method that can accept a plain array from Java. The C code can then fill it with the data requested before returning to Java. The JNI documentation shows how to do it.
13 May 2021 by Member 15076657
I have passed a hashmap from java to C. Now, I need to fill the hashmap and pass it back to java. This is my java code. Main.java import java.util.*; public class Main { static { System.loadLibrary("Tests"); } public void doProcess()...
13 May 2021 by Richard MacCutchan
You cannot use native methods to access a Java object in JNI. You can only use the Java types as defined in jni.h. So you have to figure out in your C code what the structure is and update it from that information. But it would be much simpler to...
14 May 2021 by Member 15076657
I have been trying data from C file to java using JNI. But, when I try to pass it, the following error occurs in eclipse. # # A fatal error has been detected by the Java Runtime Environment: # # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at...
14 May 2021 by Rick York
The cause is in the message : writing address 0x0000018c That is obviously an invalid address for a pointer. There is another clue : Java frames: (J=compiled Java code, j=interpreted, Vv=VM code) j Main.service(Ljava/util/HashMap;)V+0 j ...
14 May 2021 by OriginalGriff
Repost: deleted. How many times are you going to post the same thing until you start listening and actually learning?
14 May 2021 by Richard MacCutchan
As I have tried to explain to you on many occasions, you cannot access Java objects form C except by using the types and code defined in the JNI documentation. A C++ map type is completely different from a Java Map type. I also suggested that you...
16 May 2021 by 15160877
I am trying to pass a LPWSTR to java via JNI. But, it only passes the first character of the string. Can someone suggest what to do? I'm passing the string like the following: jstring k = (*env)->NewStringUTF(env, lpstr); ...
16 May 2021 by Rick York
It's acting like the JNI is expecting single-wide characters for that function because in a wide string the second byte of the pair will be zero for characters less than 256 so the function is seeing a string of a single character. Your options...
16 May 2021 by KarstenK
Working with strings isnt so easy at all because every string has "under the hood" some encoding logic. This mean HOW the buffer of bytes is interpreted to the human readable string. Try also Memory view to see the details byte by byte. For this...
18 May 2021 by another_newbie
By looking at the definition of jbyte in jni.h I have: typedef int8_t jbyte; /* signed 8 bits */ So is it is always safe to convert jbyte to a signed integer without casting? What I have tried: So far I have tried int8_t