Skip to main content

All Questions

0 votes
1 answer
73 views

Callback function's byte parameter has value out of bounds in project Panama function interface

I'm using the new Foreign function & memory API which is part of project Panama and available in preview in JAVA 19. This is a simple Java callback function public static byte addFive(byte t) { ...
Tristan's user avatar
  • 2,058
0 votes
0 answers
918 views

"CallObjectMethod" in JNI-Callback returns NULL

I have a JNI-Interface between C++ and Java. I want to pass a callback function as a parameter in a function on java side. This will be called later in C ++ via JNI and should return me a string. This ...
TheValbo's user avatar
-1 votes
1 answer
1k views

JNI error - cant call [method] when using CallVoidMethod

My goal is to have an infinite loop in the c code that does a callback passing a String to a Java function. The Java function then uses the String to update the contents of a textbox. The problem is ...
J.P. Denoyer's user avatar
2 votes
2 answers
460 views

Java Invocation API: Call the C function back from the java code

I have a C (navive) program and a jar file with the main() method. From my native program I am initializing the JVM, and calling the main() method. I have no problems with this, everything is ...
Netherwire's user avatar
  • 2,747
0 votes
0 answers
175 views

Implement callback function as interface in JNI and save reference in the function pointer

So basically I have such struct in the C++ side: typedef int(*callback)(int, int); typedef struct InfoCallback { int a; int b; callback call; } InfoCallback_t; And I would very much ...
Lisek's user avatar
  • 773
0 votes
0 answers
433 views

Jni - Call c++ method from java using void pointers

Is there any way to call a native (c++) method from java using the method's function pointer? Basically i want to use this for callbacks. Once a certain event in java get's fired, i want java to call ...
Leso_KN's user avatar
  • 178
1 vote
1 answer
3k views

JNI callback to Java from c++ class crashing

I'm trying to call a Java function from a C++ class using JNI on Android. I have searched and searched but haven't found my exact case. I can call methods in my c++ library from Java, but am having ...
ErnieB's user avatar
  • 49
1 vote
1 answer
834 views

How to pass array to java method from jni

I am trying to pass a int array from JNI to Java. When I pass single or multiple int value, it works but passing array is not working. Every time app crash and return the following error Error ...
shantanu's user avatar
  • 2,408
1 vote
0 answers
372 views

Getting crash in JNI callback from C to Java

I am using a third party C native library which is calling callbacks to my JNI. So in my JNI's C portion, I have a callback function callback() which i registered to the library while initialization. ...
Naveen's user avatar
  • 8,094
1 vote
1 answer
3k views

JNI callback passed to C

I have a java callback function I want to pass to a C++ wrapper that will in turn pass it to a C/C++ function. How would I do this? I imagine the wrapper has to create some type of C++ lambda ...
Caleb Merchant's user avatar
2 votes
1 answer
572 views

Accessed stale local reference passing short[] from JNI to Java

Hello I'm writing a program for Android with Java and JNI. I'm caching JavaVM*, a global ref jclass and 2 methodsID in the onLoad(). Then from myCallback(), which is running on a separate thread, I ...
Stefano Vuerich's user avatar
1 vote
1 answer
961 views

Call Java method from JNI after callback is received

I'm building a JNI app. From my JNI code I want to call a java funcion that updated the UI. Basically when I receive a callback and try to get the reference to the environment I get an error of ...
Stefano Vuerich's user avatar
1 vote
1 answer
3k views

JVM crashing on attachCurrentThread JNI callback invocation

Hope you are doing well. I have a JNI implementation in C wherein a C function attach to current JVM thread and callback a Java method, which is actually crashing the JVM upon attachCurrentThread() ...
srvnn's user avatar
  • 75
1 vote
2 answers
1k views

How to implement a callback function that calls from Java to C++?

I have a native C++ application that creates a JVM via JNI, instantiates a Java class (an Akka Actor) and invokes asynchronous non-blocking functions on it. I do this using JNI in C++ see snippet ...
SkyWalker's user avatar
  • 14.1k
1 vote
2 answers
682 views

JNI: Callback from JVM to C++ fails to run

I start JVM from C++ program. C++ code: JNIEXPORT jobject JNICALL com_javelin_JavelinMarketData_callBackIntoNative(JNIEnv* env, jobject obj, jlong ptr) { std::cout << "...
Andrey Rubliov's user avatar

15 30 50 per page