KNIEXPORT void KNI_GetSuperClass(jclass classHandle, jclass superclassHandle) { kni_clear_handle(superclassHandle); // just in case there's no superclass JavaClassObj::Raw sub_mirror = kni_read_handle(classHandle); GUARANTEE(sub_mirror.not_null(), "null argument to KNI_GetSuperClass"); JavaClass::Raw sub_class = sub_mirror().java_class(); JavaClass::Raw super_class = sub_class().super(); if (super_class.not_null()) { JavaClassObj::Raw m = super_class().java_mirror(); kni_set_handle(superclassHandle, m.obj()); } }
// // Class and interface operations // KNIEXPORT void KNI_FindClass(const char* name, jclass classHandle) { SETUP_ERROR_CHECKER_ARG; UsingFastOops fast_oops; kni_clear_handle(classHandle); // just in case class is not found, or // OutOfMemory // Find the class Symbol::Fast class_name = SymbolTable::symbol_for(name _KNI_CHECK); ArrayClass::Fast ac; if (FieldType::is_array(&class_name)) { FieldType::Raw ft = TypeSymbol::parse_array_class_name(&class_name _KNI_CHECK); ac = ft().object_type(); JavaClass::Raw jc = ac().obj(); while (jc().is_obj_array_class()) { ObjArrayClass::Raw oac = jc().obj(); jc = oac().element_class(); } if (jc().is_instance_class()) { InstanceClass::Raw ic = jc().obj(); if (ic.not_null() && !ic().is_fake_class() && ic().is_initialized()) { kni_set_handle(classHandle, ac().java_mirror()); } } else { GUARANTEE(jc().is_type_array_class(), "unknown kind class"); #if ENABLE_ISOLATES JavaClassObj::Raw result = ac().get_or_allocate_java_mirror(_KNI_SINGLE_ARG_CHECK); kni_set_handle(classHandle, result.obj()); #else kni_set_handle(classHandle, ac().java_mirror()); #endif } } else { LoaderContext top_ctx(&class_name, ErrorOnFailure); InstanceClass::Raw ic = SystemDictionary::find(&top_ctx, /*lookup_only=*/ true, /*check_only= */ true _KNI_CHECK); if (ic.not_null() && ic().is_initialized()) { kni_set_handle(classHandle, ic().java_mirror()); } } }
KNIEXPORT void KNI_GetClassPointer(jclass toHandle) { JavaFrame frame(Thread::current()); Method::Raw method = frame.method(); jint holder_id = method().holder_id(); OopDesc* java_class = Universe::class_list()->obj_at(holder_id); JavaClass::Raw jc = java_class; #if ENABLE_ISOLATES // At this point, it is possible that the class perhaps is still being // initialized, in which case jc().java_mirror() would return NULL. TaskMirror::Raw tm = jc().real_task_mirror(); JavaClassObj::Raw m = tm().real_java_mirror(); #else JavaClassObj::Raw m = jc().java_mirror(); #endif kni_set_handle(toHandle, m.obj()); }