我正在尝试在jthrowable中访问消息,同时处理在找不到类时生成的异常.但是,我无法在jthrowable对象上访问getMessage()的消息ID,我不知道为什么.我已经尝试将getMessage的签名更改为“()L
java / lang / String”(最后没有分号,但这是必要的,对吧?)没有快乐.我对此很困惑.我甚至尝试用toString替换getMessage,但这不起作用.显然我在这里做了一些非常错误的事情.
这是我正在使用的代码:
jthrowable java_exception; jclass java_class; jmethodID method; java_exception = (*jEnv)->ExceptionOccurred(jEnv); assert (java_exception != NULL); java_class = (*jEnv)->GetObjectClass (jEnv,java_exception); assert (java_class != NULL); method = (*jEnv)->GetMethodID (jEnv,java_class,"getMessage","()Ljava/lang/String;"); if (method == NULL) { printf ("SerIoUsly,how do I get here?!\n"); (*jEnv)->ExceptionDescribe (jEnv); return; }
SerIoUsly,how do I get here?!
Exception in thread “main” java.lang.NoClassDefFoundError: com/planet/core360/docgen/Processor
javap -p -s java.lang.Throwable给了我这个:
Compiled from “Throwable.java”
public class java.lang.Throwable extends java.lang.Object implements java.io.Serializable{
…
public java.lang.String getMessage();
Signature: ()Ljava/lang/String;
…