Example #1
0
/**
 * 例外を取得する
 */
jc_sp<JniException> JniWrapper::popException() {
    CALL_JNIENV();
    jthrowable throwable = env->ExceptionOccurred();
    if (throwable) {
        env->ExceptionClear();
    }
    jc_sp<JniException> managed = JniException::global(throwable);
    return managed;
}
Example #2
0
/**
 * スレッド名を指定する
 */
void JavaJointThread::setName(String name) {
    Thread::setName(name);

    CALL_JNIENV();
    jstring jName = env->NewStringUTF(name.c_str());
    {
        nativeThread->setThreadName(jName);
    }
    env->DeleteLocalRef(jName);
}
Example #3
0
/**
 * 例外が発生していたら例外を投げる。
 * 例外を取得する。
 * exceptionがNULLの場合、popのみを行う。
 */
void JniWrapper::throwHasException() {

    CALL_JNIENV();
    jthrowable throwable = env->ExceptionOccurred();
    if (throwable) {
        env->ExceptionClear();
        env->DeleteLocalRef(throwable);

        throw create_exception(JavaMethodException, "throwHasException()");
    }
}
Example #4
0
/**
 * メソッドを読み込む。
 */
jmethodID JniWrapper::loadMethod(jclass clazz, const charactor* name, const charactor* signeture, jcboolean isStatic) {
    CALL_JNIENV();

    jmethodID result = NULL;
    if (isStatic) {
        result = env->GetStaticMethodID(clazz, name, signeture);
    } else {
        result = env->GetMethodID(clazz, name, signeture);
    }

    // 読み込んだメソッドIDを出力
    if (result == NULL) {
        jclogf("Method Load Error !! Name %s = id %d", name, (s32)result);
    }

    return result;
}
Example #5
0
static void initialize_AssertError() {
    // loaded !
    if (class_AssertError) {
        return;
    }

    CALL_JNIENV();

    // load class object
    class_AssertError = env->FindClass(AssertError::CLASS_SIGNATURE);
    class_AssertError = (jclass)::ndk::change_globalref(env, class_AssertError);
    

    // load methods
    {

    }
}
Example #6
0
static void initialize_NativeAppUtil() {
    // loaded !
    if (class_NativeAppUtil) {
        return;
    }

    CALL_JNIENV();

    // load class object
    class_NativeAppUtil = env->FindClass(NativeAppUtil::CLASS_SIGNATURE);
    class_NativeAppUtil = (jclass)::ndk::change_globalref(env, class_NativeAppUtil);


    // load methods
    {
        methods_NativeAppUtil[0] = ::ndk::JniWrapper::loadMethod(class_NativeAppUtil, "getAPILevel", "()I", true);
        methods_NativeAppUtil[1] = ::ndk::JniWrapper::loadMethod(class_NativeAppUtil, "printStackTrace", "(Ljava/lang/Exception;)V", true);

    }
}
static void initialize_JniRuntimeException() {
    // loaded !
    if (class_JniRuntimeException) {
        return;
    }

    CALL_JNIENV();

    // load class object
    class_JniRuntimeException = env->FindClass(JniRuntimeException::CLASS_SIGNATURE);
    class_JniRuntimeException = (jclass)::ndk::change_globalref(env, class_JniRuntimeException);
    

    // load methods
    {
        methods_JniRuntimeException[0] = ::ndk::JniWrapper::loadMethod(class_JniRuntimeException, "printStackTrace", "()V", false);
        methods_JniRuntimeException[1] = ::ndk::JniWrapper::loadMethod(class_JniRuntimeException, "getMessage", "()Ljava/lang/String;", false);

    }
}
Example #8
0
static void initialize_NativeIOUtil() {
    // loaded !
    if (class_NativeIOUtil) {
        return;
    }

    CALL_JNIENV();

    // load class object
    class_NativeIOUtil = env->FindClass(NativeIOUtil::CLASS_SIGNATURE);
    class_NativeIOUtil = (jclass)::ndk::change_globalref(env, class_NativeIOUtil);
    

    // load methods
    {
        methods_NativeIOUtil[0] = ::ndk::JniWrapper::loadMethod(class_NativeIOUtil, "openFromAssets", "(Ljava/lang/String;Landroid/content/Context;)Ljava/io/InputStream;", true);
        methods_NativeIOUtil[1] = ::ndk::JniWrapper::loadMethod(class_NativeIOUtil, "openFromExternalStrage", "(Ljava/lang/String;Landroid/content/Context;)Ljava/io/InputStream;", true);

    }
}
static void initialize_NativeTouchEvent() {
    // loaded !
    if (class_NativeTouchEvent) {
        return;
    }

    CALL_JNIENV();

    // load class object
    class_NativeTouchEvent = env->FindClass(NativeTouchEvent::CLASS_SIGNATURE);
    class_NativeTouchEvent = (jclass)::ndk::change_globalref(env, class_NativeTouchEvent);


    // load methods
    {
        methods_NativeTouchEvent[0] = ::ndk::JniWrapper::loadMethod(class_NativeTouchEvent, "getTouchID", "()I", false);
        methods_NativeTouchEvent[1] = ::ndk::JniWrapper::loadMethod(class_NativeTouchEvent, "getEventPosX", "()F", false);
        methods_NativeTouchEvent[2] = ::ndk::JniWrapper::loadMethod(class_NativeTouchEvent, "toString", "()Ljava/lang/String;", false);
        methods_NativeTouchEvent[3] = ::ndk::JniWrapper::loadMethod(class_NativeTouchEvent, "getEventType", "()I", false);
        methods_NativeTouchEvent[4] = ::ndk::JniWrapper::loadMethod(class_NativeTouchEvent, "getEventPosY", "()F", false);

    }
}
jint NativeTouchEvent::getEventType() {
    CALL_JNIENV();
    return (jint) env->CallIntMethod(this->getObject(), methods_NativeTouchEvent[3]);
}
jstring JniRuntimeException::getMessage_(jobject _this) {
    CALL_JNIENV();
    initialize_JniRuntimeException();
    return (jstring) env->CallObjectMethod(_this, methods_JniRuntimeException[1]);
}
jstring JniRuntimeException::getMessage() {
    CALL_JNIENV();
    return (jstring) env->CallObjectMethod(this->getObject(), methods_JniRuntimeException[1]);
}
void JniRuntimeException::printStackTrace_(jobject _this) {
    CALL_JNIENV();
    initialize_JniRuntimeException();
    env->CallVoidMethod(_this, methods_JniRuntimeException[0]);
}
void JniRuntimeException::printStackTrace() {
    CALL_JNIENV();
    env->CallVoidMethod(this->getObject(), methods_JniRuntimeException[0]);
}
Example #15
0
jobject NativeIOUtil::openFromAssets_unsafe(jstring fileName, jobject appContext) {
    CALL_JNIENV();
    initialize_NativeIOUtil();
    return (jobject) env->CallStaticObjectMethod(class_NativeIOUtil, methods_NativeIOUtil[0], fileName, appContext);
}
jfloat NativeTouchEvent::getEventPosY_(jobject _this) {
    CALL_JNIENV();
    initialize_NativeTouchEvent();
    return (jfloat) env->CallFloatMethod(_this, methods_NativeTouchEvent[4]);
}
jfloat NativeTouchEvent::getEventPosY() {
    CALL_JNIENV();
    return (jfloat) env->CallFloatMethod(this->getObject(), methods_NativeTouchEvent[4]);
}
Example #18
0
jint NativeAppUtil::getAPILevel() {
    CALL_JNIENV();
    initialize_NativeAppUtil();
    return (jint) env->CallStaticIntMethod(class_NativeAppUtil, methods_NativeAppUtil[0]);
}
jstring NativeTouchEvent::toString_(jobject _this) {
    CALL_JNIENV();
    initialize_NativeTouchEvent();
    return (jstring) env->CallObjectMethod(_this, methods_NativeTouchEvent[2]);
}
jstring NativeTouchEvent::toString() {
    CALL_JNIENV();
    return (jstring) env->CallObjectMethod(this->getObject(), methods_NativeTouchEvent[2]);
}
Example #21
0
jobject NativeIOUtil::openFromExternalStrage_unsafe(jstring path, jobject appContext) {
    CALL_JNIENV();
    initialize_NativeIOUtil();
    return (jobject) env->CallStaticObjectMethod(class_NativeIOUtil, methods_NativeIOUtil[1], path, appContext);
}
Example #22
0
void NativeAppUtil::printStackTrace(jobject e) {
    CALL_JNIENV();
    initialize_NativeAppUtil();
    env->CallStaticVoidMethod(class_NativeAppUtil, methods_NativeAppUtil[1], e);
}
jint NativeTouchEvent::getEventType_(jobject _this) {
    CALL_JNIENV();
    initialize_NativeTouchEvent();
    return (jint) env->CallIntMethod(_this, methods_NativeTouchEvent[3]);
}