Beispiel #1
0
void* _bcLookupInterfaceMethodImpl(Env* env, ClassInfoHeader* header, Object* thiz, uint32_t index) {
    TypeInfo* typeInfo = header->typeInfo;
    ITables* itables = thiz->clazz->itables;
    ITable* itable = itables->cache;
    if (itable->typeInfo == typeInfo) {
        return itable->table.table[index];
    }
    uint32_t i;
    for (i = 0; i < itables->count; i++) {
        itable = itables->table[i];
        if (itable->typeInfo == typeInfo) {
            itables->cache = itable;
            return itable->table.table[index];
        }
    }

    ENTER;
    initializeClass(env, header);
    Class* ownerInterface = header->clazz;
    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);
    LEAVE(NULL);
}
Beispiel #2
0
/**
 * @brief Inicializa a JVM; Aloca memória para as estruturas principais;
 Chama o carregador para a primeira classe; inicializa a primeira classe
 *
 * @param classHeap
 * @param objectHeap
 * @param stackFrame
 * @param classPathF_ptr
 */
void jvmStartup(ClassFile *classHeap_ptr, Object *objectHeap_ptr, Frame *stackFrame_ptr, FILE *classPathF_ptr, dataMSize_t *dmSize_ptr){
    classHeap_ptr = malloc( CLSHEAP_MAX*sizeof( ClassFile ) );
    objectHeap_ptr = malloc( OBJHEAP_MAX*sizeof( Object_t ) );
    stackFrame_ptr = malloc( STKFRAME_MAX*sizeof( Frame ) );
    
    dmSize_ptr->clsHeap_size = 0;
    dmSize_ptr->objHeap_size = 0;
    dmSize_ptr->stkHeap_size = 0;
    
    //Carrega a classe inicial
    //OK! 
    loadClass(classPathF_ptr, classHeap_ptr, dmSize_ptr);
   	printf("\nstatic_values_size %d", classHeap_ptr->static_values_size); 
	for(int i = 0; i < classHeap_ptr->static_values_size; i++)
		printf("\nname %s", classHeap_ptr->static_values[i].field_name);
    //Checa a consistência da classe
    printf("\n\nConteudo do .class");
    printf("\n--------------------------------");
    print_ClassFile(classHeap_ptr);
    //Inicializa a classe inicial, roda clinit

	//OK!
    initializeClass(classHeap_ptr, stackFrame_ptr, dmSize_ptr, classHeap_ptr);
    //initializeClass(classHeap_ptr, stackFrame_ptr, &dmSize_ptr->stkHeap_size); //Sei que o primeiro elemento da classHeap é a classe inicial
	
	//Chamo o método main
	callMethod(classHeap_ptr, stackFrame_ptr, dmSize_ptr, classHeap_ptr, "main", "([Ljava/lang/String;)V");


}
Beispiel #3
0
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;
}
Beispiel #4
0
void LSLuaState::initializeLuaTypes(const utArray<Type *>& types)
{
    for (UTsize i = 0; i < types.size(); i++)
    {
        types[i]->cache();
    }

    // initialize all classes
    for (UTsize i = 0; i < types.size(); i++)
    {
        initializeClass(types[i]);
    }

    // run static initializers now that all classes have been initialized
    for (UTsize i = 0; i < types.size(); i++)
    {
        lsr_classinitializestatic(VM(), types[i]);
    }
}
Beispiel #5
0
void Java_java_lang_Class_forName(void)
{
    START_TEMPORARY_ROOTS
        DECLARE_TEMPORARY_ROOT(STRING_INSTANCE, string, 
                               topStackAsType(STRING_INSTANCE));
    
        if (string == NULL) {
            raiseException(NullPointerException);
        } else {
            long length = string->length;
            CLASS thisClass = NULL;
            DECLARE_TEMPORARY_ROOT(char*, className, mallocBytes(length + 1));
            getStringContentsSafely(string, className, length + 1);
            if (strchr(className, '/') == NULL) {
                replaceLetters(className,'.','/');
                if (verifyName(className, LegalClass, FALSE)) {
                    thisClass = 
                        getClassX((CONST_CHAR_HANDLE)&className, 0, length);
                    /* The specification does not require that the current
                     * class have "access" to thisClass */
                }
            }
            if (thisClass != NULL) {
                topStackAsType(CLASS) = thisClass;
                if (!IS_ARRAY_CLASS(thisClass)) {
                    if (!CLASS_INITIALIZED((INSTANCE_CLASS)thisClass)) {
                        initializeClass((INSTANCE_CLASS)thisClass);
                    }
                }
            } else { 
                raiseExceptionMsg("java/lang/ClassNotFoundException", 
                                  string);
            }
        }
    END_TEMPORARY_ROOTS
}
Beispiel #6
0
void _bcInitializeClass(Env* env, ClassInfoHeader* header) {
    ENTER;
    initializeClass(env, header);
    LEAVEV;
}
Beispiel #7
0
 int Modifier::isAbstract(int mod)
 {
     jclass cls = initializeClass();
     return (int) env->callStaticBooleanMethod(cls, _mids[mid_isAbstract], mod);
 }