• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ rvmExceptionCheck函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中rvmExceptionCheck函数的典型用法代码示例。如果您正苦于以下问题:C++ rvmExceptionCheck函数的具体用法?C++ rvmExceptionCheck怎么用?C++ rvmExceptionCheck使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了rvmExceptionCheck函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: wrapClassNotFoundException

static void wrapClassNotFoundException(Env* env, const char* className) {
    Object* exception = rvmExceptionOccurred(env);
    if (exception && exception->clazz == java_lang_ClassNotFoundException) {
        // If ClassNotFoundException is thrown we have to wrap it in a NoClassDefFoundError
        exception = rvmExceptionClear(env);
        Method* constructor = rvmGetInstanceMethod(env, java_lang_NoClassDefFoundError, "<init>", "(Ljava/lang/String;)V");
        if (!constructor) return;
        Object* message = rvmNewStringUTF(env, className, -1);
        if (!message) return;
        Object* wrappedException = rvmNewObject(env, java_lang_NoClassDefFoundError, constructor, message);
        if (!wrappedException) return;
        Class* java_lang_StackTraceElement = rvmFindClassUsingLoader(env, "java/lang/StackTraceElement", NULL);
        if (!java_lang_StackTraceElement) return;
        ObjectArray* stackTrace = rvmNewObjectArray(env, 0, java_lang_StackTraceElement, NULL, NULL);
        if (!stackTrace) return;
        Method* setStackTrace = rvmGetInstanceMethod(env, java_lang_Throwable, "setStackTrace", "([Ljava/lang/StackTraceElement;)V");
        if (!setStackTrace) return;
        rvmCallVoidInstanceMethod(env, wrappedException, setStackTrace, stackTrace);
        if (rvmExceptionCheck(env)) return;
        Method* initCause = rvmGetInstanceMethod(env, java_lang_NoClassDefFoundError, "initCause", "(Ljava/lang/Throwable;)Ljava/lang/Throwable;");
        if (!initCause) return;
        rvmCallObjectInstanceMethod(env, wrappedException, initCause, exception);
        if (!rvmExceptionCheck(env)) rvmThrow(env, wrappedException);
    }
}
开发者ID:SinoJerk,项目名称:robovm,代码行数:25,代码来源:bc.c


示例2: _bcSetObjectArrayElement

void _bcSetObjectArrayElement(Env* env, ObjectArray* array, jint index, Object* value) {
    if (!value) {
        array->values[index] = value;
        return;        
    }
    ENTER;
    Class* componentType = array->object.clazz->componentType;
    jboolean assignable = rvmIsAssignableFrom(env, value->clazz, componentType);
    if (!rvmExceptionCheck(env) && !assignable) {
        rvmThrowArrayStoreException(env, value->clazz, array->object.clazz);
    }
    if (!rvmExceptionCheck(env)) array->values[index] = value;
    LEAVEV;
}
开发者ID:SinoJerk,项目名称:robovm,代码行数:14,代码来源:bc.c


示例3: implementAbstractInterfaceMethods

/**
 * Implements all abstract methods in {@code proxyClass}. This should be called after
 * {@link #addProxyMethods()} which will override all methods defined by the proxy's
 * ancestor classes (abstract or concrete).
 */
static jboolean implementAbstractInterfaceMethods(Env* env, Class* proxyClass, Interface* interface, ProxyClassData* proxyClassData) {
    if (!interface) return TRUE;

    Method* method = rvmGetMethods(env, interface->interface);
    if (rvmExceptionOccurred(env)) return FALSE;
    for (; method != NULL; method = method->next) {
        if (!METHOD_IS_CLASS_INITIALIZER(method)) {
            ProxyMethod* proxyMethod = hasMethod(env, proxyClass, method->name, method->desc);
            if (rvmExceptionOccurred(env)) return FALSE;
            if (!proxyMethod) { 
                jint access = (method->access & (~ACC_ABSTRACT)) | ACC_FINAL;
                proxyMethod = addProxyMethod(env, proxyClass, method, access, _proxy0);
                if (!proxyMethod) return FALSE;
            }
            // Record the lookup function in proxyClassData
            LookupEntry* entry = rvmAllocateMemory(env, sizeof(LookupEntry));
            if (!entry) return FALSE;
            entry->key.name = method->name;
            entry->key.desc = method->desc;
            entry->method = proxyMethod;
            HASH_ADD(hh, proxyClassData->lookupsHash, key, sizeof(LookupKey), entry);
        }
    }

    if (!implementAbstractInterfaceMethods(env, proxyClass, interface->next, proxyClassData)) return FALSE;
    Interface* interfaceInterfaces = rvmGetInterfaces(env, interface->interface);
    if (rvmExceptionCheck(env)) return FALSE;
    if (!implementAbstractInterfaceMethods(env, proxyClass, interfaceInterfaces, proxyClassData)) return FALSE;

    return TRUE;
}
开发者ID:John-Chan,项目名称:robovm,代码行数:36,代码来源:proxy.c


示例4: getRuntimeVisibleAnnotationsIterator

static jboolean getRuntimeVisibleAnnotationsIterator(Env* env, jbyte type, void* attributes, void* data) {
    ObjectArray** result = (ObjectArray**) ((void**) data)[0];
    Object* classLoader = (Object*) ((void**) data)[1];
    if (type == RUNTIME_VISIBLE_ANNOTATIONS) {
        jint length = getInt(&attributes);
        ObjectArray* annotations = rvmNewObjectArray(env, length, java_lang_annotation_Annotation, NULL, NULL);
        if (!annotations) return FALSE;
        jint i = 0;
        jint actualLength = 0;
        for (i = 0; i < length; i++) {
            jvalue value = {0};
            if (getAnnotationValue(env, &attributes, NULL, classLoader, &value, TRUE)) {
                annotations->values[actualLength++] = (Object*) value.l;
            } else if (rvmExceptionCheck(env)) {
                return FALSE;
            }
        }
        if (actualLength != length) {
            // One or more annotations could not be loaded due to a missing class.
            // Reallocate the result array and copy over the non null values.
            ObjectArray* annotations2 = rvmNewObjectArray(env, actualLength, java_lang_annotation_Annotation, NULL, NULL);
            if (!annotations2) return FALSE;
            memcpy(annotations2->values, annotations->values, actualLength * sizeof(Object*));
            annotations = annotations2;
        }
        *result = annotations;
        return FALSE; // Stop iterating
    }
    return TRUE; // Continue with next attribute
}
开发者ID:Zubnix,项目名称:aura,代码行数:30,代码来源:attribute.c


示例5: lookupInterfaceMethod

void* lookupInterfaceMethod(Env* env, ClassInfoHeader* header, Object* thiz, char* name, char* desc) {
    initializeClass(env, header);
    if (rvmExceptionCheck(env)) return NULL;
    Class* ownerInterface = header->clazz;
    if (!rvmIsInstanceOf(env, thiz, ownerInterface)) {
        char message[256];
        snprintf(message, 256, "Class %s does not implement the requested interface %s", 
            rvmToBinaryClassName(env, thiz->clazz->name), rvmToBinaryClassName(env, ownerInterface->name));
        rvmThrowIncompatibleClassChangeError(env, message);
        return NULL;
    }
    Method* method = rvmGetInstanceMethod(env, thiz->clazz, name, desc);
    Object* throwable = rvmExceptionClear(env);
    if (!method && throwable->clazz != java_lang_NoSuchMethodError) { 
        rvmThrow(env, throwable);
        return NULL;
    }
    if (!method || METHOD_IS_ABSTRACT(method)) {
        rvmThrowAbstractMethodError(env, ""); // TODO: Message
        return NULL;
    }
    if (!METHOD_IS_PUBLIC(method)) {
        rvmThrowIllegalAccessError(env, ""); // TODO: Message
        return NULL;
    }
    return method->synchronizedImpl ? method->synchronizedImpl : method->impl;
}
开发者ID:SinoJerk,项目名称:robovm,代码行数:27,代码来源:bc.c


示例6: rvmProxyCreateProxyClass

Class* rvmProxyCreateProxyClass(Env* env, Class* superclass, ClassLoader* classLoader, char* className, jint interfacesCount, Class** interfaces, 
        jint instanceDataSize, jint instanceDataOffset, unsigned short instanceRefCount, ProxyHandler handler) {

    // Allocate the proxy class.
    Class* proxyClass = rvmAllocateClass(env, className, superclass, classLoader, CLASS_TYPE_PROXY | ACC_PUBLIC | ACC_FINAL, 
        offsetof(Class, data) + sizeof(ProxyClassData), instanceDataSize, instanceDataOffset, 1, instanceRefCount, NULL, NULL);
    if (!proxyClass) return NULL;

    ProxyClassData* proxyClassData = (ProxyClassData*) proxyClass->data;
    proxyClassData->handler = handler;

    // Add interfaces
    jint i;
    for (i = 0; i < interfacesCount; i++) {
        if (!rvmAddInterface(env, proxyClass, (Class*) interfaces[i])) return NULL;
    }

    // Initialize methods to NULL to prevent rvmGetMethods() from trying to load the methods if called with this proxy class
    proxyClass->_methods = NULL;

    Class* c = proxyClass;
    while (c) {
        Interface* interface = rvmGetInterfaces(env, c);
        if (rvmExceptionCheck(env)) return NULL;
        if (!implementAbstractInterfaceMethods(env, proxyClass, interface, proxyClassData)) return NULL;
        c = c->superclass;
    }

    if (!addProxyMethods(env, proxyClass, superclass, proxyClassData)) return NULL;

    if (!rvmRegisterClass(env, proxyClass)) return NULL;

    return proxyClass;
}
开发者ID:John-Chan,项目名称:robovm,代码行数:34,代码来源:proxy.c


示例7: Java_java_lang_Class_classForName

Class* Java_java_lang_Class_classForName(Env* env, Class* cls, Object* className, jboolean initializeBoolean,
            ClassLoader* classLoader) {

    if (!className) {
        rvmThrowNullPointerException(env);
        return NULL;
    }
    char* classNameUTF = toBinaryName(env, className);
    if (!classNameUTF) return NULL;
    Class* clazz = rvmFindClassUsingLoader(env, classNameUTF, classLoader);
    if (!clazz) {
        char* p = classNameUTF;
        while (*p != '\0') {
            if (*p == '/') *p = '.';
            p++;
        }
        WARNF("Class.forName() failed to load '%s'. "
              "Use the -forcelinkclasses command line option "
              "or add <forceLinkClasses><pattern>%s</pattern></forceLinkClasses> "
              "to your robovm.xml file to link it in.",
              classNameUTF, classNameUTF);
        return NULL;
    }
    if (initializeBoolean) {
        rvmInitialize(env, clazz);
        if (rvmExceptionCheck(env)) return NULL;
    }
    return clazz;
}
开发者ID:Andorion,项目名称:robovm,代码行数:29,代码来源:java_lang_Class.c


示例8: Java_java_lang_Class_getDeclaredFields0

ObjectArray* Java_java_lang_Class_getDeclaredFields0(Env* env, Class* clazz, jboolean publicOnly) {
    if (CLASS_IS_PRIMITIVE(clazz) || CLASS_IS_ARRAY(clazz)) return NULL;

    Field* fields = rvmGetFields(env, clazz);
    if (rvmExceptionCheck(env)) return NULL;

    Field* field;
    jint length = 0;
    for (field = fields; field != NULL; field = field->next) {
        if (!publicOnly || FIELD_IS_PUBLIC(field)) {
            length++;
        }
    }

    ObjectArray* result = NULL;
    jint i = 0;
    for (field = fields; field != NULL; field = field->next) {
        if (!publicOnly || FIELD_IS_PUBLIC(field)) {
            Object* c = createFieldObject(env, field);
            if (!c) return NULL;
            if (!result) {
                result = rvmNewObjectArray(env, length, c->clazz, NULL, NULL);
                if (!result) return NULL;
            }
            result->values[i++] = c;
        }
    }

    return result;
}
开发者ID:Andorion,项目名称:robovm,代码行数:30,代码来源:java_lang_Class.c


示例9: Java_java_lang_Class_getDeclaredMethods0

ObjectArray* Java_java_lang_Class_getDeclaredMethods0(Env* env, Class* clazz, jboolean publicOnly) {
    if (CLASS_IS_PRIMITIVE(clazz) || CLASS_IS_ARRAY(clazz)) return NULL;

    Method* methods = rvmGetMethods(env, clazz);
    if (rvmExceptionCheck(env)) return NULL;

    Method* method;
    jint length = 0;
    for (method = methods; method != NULL; method = method->next) {
        if (!METHOD_IS_CONSTRUCTOR(method) && !METHOD_IS_CLASS_INITIALIZER(method)) {
            if (!publicOnly || METHOD_IS_PUBLIC(method)) {
                length++;
            }
        }
    }

    ObjectArray* result = NULL;
    jint i = 0;
    for (method = methods; method != NULL; method = method->next) {
        if (!METHOD_IS_CONSTRUCTOR(method) && !METHOD_IS_CLASS_INITIALIZER(method)) {
            if (!publicOnly || METHOD_IS_PUBLIC(method)) {
                Object* c = createMethodObject(env, method);
                if (!c) return NULL;
                if (!result) {
                    result = rvmNewObjectArray(env, length, c->clazz, NULL, NULL);
                    if (!result) return NULL;
                }
                result->values[i++] = c;
            }
        }
    }

    return result;
}
开发者ID:Andorion,项目名称:robovm,代码行数:34,代码来源:java_lang_Class.c


示例10: rvmGetMethods

Method* rvmGetMethods(Env* env, Class* clazz) {
    if (clazz->_methods != &METHODS_NOT_LOADED) return clazz->_methods;

    // TODO: Double checked locking
    obtainClassLock();
    if (clazz->_methods == &METHODS_NOT_LOADED) {
        env->vm->options->loadMethods(env, clazz);
        if (clazz->_methods == &METHODS_NOT_LOADED) {
            // The class has no methods
            clazz->_methods = NULL;
        }
    }
    if (rvmExceptionCheck(env)) clazz->_methods = &METHODS_NOT_LOADED;
    releaseClassLock();
    if (rvmExceptionCheck(env)) return NULL;
    return clazz->_methods;
}
开发者ID:John-Chan,项目名称:robovm,代码行数:17,代码来源:class.c


示例11: rvmGetInterfaces

Interface* rvmGetInterfaces(Env* env, Class* clazz) {
    if (clazz->_interfaces != &INTERFACES_NOT_LOADED) return clazz->_interfaces;

    // TODO: Double checked locking
    obtainClassLock();
    if (clazz->_interfaces == &INTERFACES_NOT_LOADED) {
        env->vm->options->loadInterfaces(env, clazz);
        if (clazz->_interfaces == &INTERFACES_NOT_LOADED) {
            // The class has no interfaces
            clazz->_interfaces = NULL;
        }
    }
    if (rvmExceptionCheck(env)) clazz->_interfaces = &INTERFACES_NOT_LOADED;
    releaseClassLock();
    if (rvmExceptionCheck(env)) return NULL;
    return clazz->_interfaces;
}
开发者ID:John-Chan,项目名称:robovm,代码行数:17,代码来源:class.c


示例12: _bcCheckcastArray

Object* _bcCheckcastArray(Env* env, Class* arrayClass, Object* o) {
    if (!o) return o;
    ENTER;
    jboolean b = rvmIsAssignableFrom(env, o->clazz, arrayClass);
    if (!rvmExceptionCheck(env) && !b) {
        rvmThrowClassCastException(env, arrayClass, o->clazz);
    }
    LEAVE(o);
}
开发者ID:SinoJerk,项目名称:robovm,代码行数:9,代码来源:bc.c


示例13: rvmGetMethod

Method* rvmGetMethod(Env* env, Class* clazz, const char* name, const char* desc) {
    Method* method = getMethod(env, clazz, name, desc);
    if (rvmExceptionCheck(env)) return NULL;
    if (!method) {
        rvmThrowNoSuchMethodError(env, name);
        return NULL;
    }
    return method;
}
开发者ID:Svyatoslavik,项目名称:robovm,代码行数:9,代码来源:method.c


示例14: findMethod

static Method* findMethod(Env* env, Class* clazz, const char* name, const char* desc) {
    Method* method = rvmGetMethods(env, clazz);
    if (rvmExceptionCheck(env)) return NULL;
    for (; method != NULL; method = method->next) {
        if (!strcmp(method->name, name) && !strcmp(method->desc, desc)) {
            return method;
        }
    }
    return NULL;
}
开发者ID:Svyatoslavik,项目名称:robovm,代码行数:10,代码来源:method.c


示例15: _bcLdcArrayClass

Object* _bcLdcArrayClass(Env* env, Class** arrayClassPtr, char* name) {
    Class* arrayClass = *arrayClassPtr;
    if (arrayClass) return (Object*) arrayClass;
    ENTER;
    arrayClass = rvmFindClassUsingLoader(env, name, systemClassLoader);
    wrapClassNotFoundException(env, name);
    if (!rvmExceptionCheck(env)) {
        *arrayClassPtr = arrayClass;
    }
    LEAVE((Object*) arrayClass);
}
开发者ID:SinoJerk,项目名称:robovm,代码行数:11,代码来源:bc.c


示例16: Java_java_lang_Class_getEnclosingClass

Class* Java_java_lang_Class_getEnclosingClass(Env* env, Class* thiz) {
    Class* enclosingClass = rvmAttributeGetEnclosingClass(env, thiz);
    if (rvmExceptionCheck(env) && rvmExceptionOccurred(env)->clazz != java_lang_ClassNotFoundException) {
        return NULL;
    }
    if (!enclosingClass) {
        rvmExceptionClear(env);
        return rvmAttributeGetDeclaringClass(env, thiz);
    }
    return enclosingClass;
}
开发者ID:Andorion,项目名称:robovm,代码行数:11,代码来源:java_lang_Class.c


示例17: _bcLdcString

Object* _bcLdcString(Env* env, Object** ptr, char* s, jint length) {
    Object* o = *ptr;
    if (o) return o;
    ENTER;
    o = rvmNewInternedStringUTF(env, s, length);
    if (!rvmExceptionCheck(env)) {
        *ptr = o;
        rvmRegisterDisappearingLink(env, (void**) ptr, o);
    }
    LEAVE(o);
}
开发者ID:SinoJerk,项目名称:robovm,代码行数:11,代码来源:bc.c


示例18: _bcCheckcast

Object* _bcCheckcast(Env* env, ClassInfoHeader* header, Object* o) {
    if (!o) return o;
    ENTER;
    Class* clazz = ldcClass(env, header);
    if (clazz) {
        jboolean b = rvmIsAssignableFrom(env, o->clazz, clazz);
        if (!rvmExceptionCheck(env) && !b) {
            rvmThrowClassCastException(env, clazz, o->clazz);
        }
    }
    LEAVE(o);
}
开发者ID:SinoJerk,项目名称:robovm,代码行数:12,代码来源:bc.c


示例19: iterateAttributes

static void iterateAttributes(Env* env, void* attributes, jboolean (*f)(Env*, jbyte, void*, void*), void* data) {
    if (!attributes) return;

    jint i, j;
    jint length = 0;
    jint numParams = 0;
    jint count = getInt(&attributes);

    while (count > 0) {
        jbyte type = getByte(&attributes);
        if (!f(env, type, attributes, data)) {
            return;
        }
        if (rvmExceptionCheck(env)) return;

        switch (type) {
        case SOURCE_FILE:
        case SIGNATURE:
            attributes += sizeof(char*);
            break;
        case INNER_CLASS:
            attributes += 3 * sizeof(char*) + sizeof(jint);
            break;
        case ENCLOSING_METHOD:
            attributes += 3 * sizeof(char*);
            break;
        case EXCEPTIONS:
            length = getInt(&attributes);
            attributes += length * sizeof(char*);
            break;
        case ANNOTATION_DEFAULT:
            skipElementValue(&attributes);
            break;
        case RUNTIME_VISIBLE_ANNOTATIONS:
            length = getInt(&attributes);
            while (length > 0) {
                skipAnnotationElementValue(&attributes);
                length--;
            }
            break;
        case RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS:
            numParams = getInt(&attributes);
            for (i = 0; i < numParams; i++) {
                length = getInt(&attributes);
                for (j = 0; j < length; j++) {
                    skipAnnotationElementValue(&attributes);
                }
            }
            break;
        }
        count--;
    }
}
开发者ID:Zubnix,项目名称:aura,代码行数:53,代码来源:attribute.c


示例20: getMethod

static Method* getMethod(Env* env, Class* clazz, const char* name, const char* desc) {
    if (!strcmp("<init>", name) || !strcmp("<clinit>", name)) {
        // Constructors and static initializers are not inherited so we shouldn't check with the superclasses.
        return findMethod(env, clazz, name, desc);
    }

    Class* c = clazz;
    for (c = clazz; c != NULL; c = c->superclass) {
        Method* method = findMethod(env, c, name, desc);
        if (rvmExceptionCheck(env)) return NULL;
        if (method) return method;
    }

    /*
     * Check with interfaces.
     * TODO: Should we really do this? Does the JNI GetMethodID() function do this?
     */
    for (c = clazz; c != NULL; c = c->superclass) {
        Interface* interfaze = rvmGetInterfaces(env, c);
        if (rvmExceptionCheck(env)) return NULL;
        for (; interfaze != NULL; interfaze = interfaze->next) {
            Method* method = getMethod(env, interfaze->interfaze, name, desc);
            if (rvmExceptionCheck(env)) return NULL;
            if (method) return method;
        }
    }

    if (CLASS_IS_INTERFACE(clazz)) {
        /*
         * Class is an interface so check with java.lang.Object.
         * TODO: Should we really do this? Does the JNI GetMethodID() function do this?
         */
        return getMethod(env, java_lang_Object, name, desc);
    }

    return NULL;
}
开发者ID:Svyatoslavik,项目名称:robovm,代码行数:37,代码来源:method.c



注:本文中的rvmExceptionCheck函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ rvmFindClassUsingLoader函数代码示例发布时间:2022-05-30
下一篇:
C++ rvec_inc函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap