============================================================================= $new() =============================================================================
| 376 | // $new() |
| 377 | //============================================================================= |
| 378 | static jobject java_new(JNIEnv* env, JavaClassWrapper* wrapper, |
| 379 | const char* constructor_sig, jvalue* args) { |
| 380 | |
| 381 | jmethodID constructor = (*env)->GetMethodID(env, wrapper->clazz, "<init>", constructor_sig); |
| 382 | if (!constructor) { |
| 383 | LOGE("Constructor not found: %s", constructor_sig); |
| 384 | (*env)->ExceptionClear(env); |
| 385 | return NULL; |
| 386 | } |
| 387 | |
| 388 | jobject instance = (*env)->NewObjectA(env, wrapper->clazz, constructor, args); |
| 389 | if ((*env)->ExceptionCheck(env)) { |
| 390 | (*env)->ExceptionDescribe(env); |
| 391 | (*env)->ExceptionClear(env); |
| 392 | LOGE("Failed to create instance"); |
| 393 | return NULL; |
| 394 | } |
| 395 | |
| 396 | LOGI("Created new instance of %s", wrapper->class_name); |
| 397 | return instance; |
| 398 | } |
| 399 | |
| 400 | //============================================================================= |
| 401 | // Static method CALL |