Calling Java Method from C++
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Rajesh_Patel
Posted On:   Friday, January 9, 2004 05:00 PM

Hello Mr. Srinivas, Sorry to bother you but I am stuck and need some help. I have a Java class call Logger, which is instantiated and used in another Java class called testCPPInterface. The later defines two native methods, String init() and void processDataC(String), and one non-native method called void logMsg(int, int, String), which in turn calls logMsg method of the Logger. The init is called to create a C++ object that defines the method processData(JNIEnv *env, jobject obj, const char*) which is invoked when the native method (C side) processDataC is called. All goes okay, except that when the Logger.logMsg is called from testCPPInterface.logMsg (which is called from processData method of the C++ object), it throws a null pointer exception. He   More>>

Hello Mr. Srinivas,

Sorry to bother you but I am stuck and need some help. I have a Java class call Logger, which is instantiated and used in another Java class called testCPPInterface. The later defines two native methods, String init() and void processDataC(String), and one non-native method called void logMsg(int, int, String), which in turn calls logMsg method of the Logger. The init is called to create a C++ object that defines the method processData(JNIEnv *env, jobject obj, const char*) which is invoked when the native method (C side) processDataC is called. All goes okay, except that when the Logger.logMsg is called from testCPPInterface.logMsg (which is called from processData method of the C++ object), it throws a null pointer exception. Here is an illustrated stack trace:

Native C++ Java (the jobject logger is the
parameter in call to instance of Logger
processDataC) created in testCPPInterface
processDataC->processData->testCPPInterface.logMsg()->logger.logMsg()

In addition, is it true that only private methods of Java class can be called from C++? If so, why?

Thanks in advance for you help and time.
Raj Patel

   <<Less
About | Sitemap | Contact