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 }
char* getStringContents(STRING_INSTANCE string){ GUARANTEE(_in_kvm_native_method, "sanity"); return getStringContentsSafely(string, str_buffer, STRINGBUFFERSIZE); }