jobject bsf_callmethod()

in src/main/java/org/apache/bsf/util/JNIUtils.c [101:130]


jobject bsf_callmethod (JNIEnv *jenv, jobject target,
			char *methodname, jobjectArray args) {
  jclass cl;
  jmethodID mid;
  jobject result;

  /* find the BSFUtils.callBeanMethod method ID if needed */
  cl = (*jenv)->FindClass (jenv, "org/apache/bsf/util/EngineUtils");
  mid = (*jenv)->GetStaticMethodID (jenv, cl, "callBeanMethod",
				      "(Ljava/lang/Object;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/Object;");
  if ((*jenv)->ExceptionOccurred (jenv)) {
      (*jenv)->ExceptionDescribe (jenv);
      (*jenv)->ExceptionClear (jenv);
      return 0;
    }
  result = (*jenv)->CallStaticObjectMethod (jenv, cl, mid, target,
					    (*jenv)->NewStringUTF (jenv,
								   methodname),
					    args);
  if ((*jenv)->ExceptionOccurred (jenv)) {
    (*jenv)->ExceptionDescribe (jenv);
    (*jenv)->ExceptionClear (jenv);
    /* I should really throw a BSF exception here and the caller should
       check whether an exception was thrown and in that case return.
       later. */
    return 0;
  } else {
    return result;
  }
}