Exemplo n.º 1
0
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());
  }
}
Exemplo n.º 2
0
KNIEXPORT jboolean KNI_IsInstanceOf(jobject objectHandle, jclass classHandle) {
  // Create handle for objectHandle
  Oop::Raw object = kni_read_handle(objectHandle);
  if (object.is_null()) {
    return KNI_TRUE;
  }
  JavaClass::Raw object_class = object.blueprint();

  // Create handle for classHandle
  JavaClassObj::Raw mirror = kni_read_handle(classHandle);
  GUARANTEE(mirror.not_null(), "null argument to KNI_IsInstanceOf");
  JavaClass::Raw other_class = mirror().java_class();

  // Do subtype check
  return CAST_TO_JBOOLEAN(object_class().is_subtype_of(&other_class));
}
Exemplo n.º 3
0
//
// 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());
    }
  }
}
Exemplo n.º 4
0
void InstanceClass::set_initialized() {
 TaskMirror::Raw tm;
 tm = task_mirror_desc();
 GUARANTEE(tm.not_null(), "task mirror must not be null");
 if (TaskMirrorDesc::is_being_initialized_mirror((TaskMirrorDesc*)tm.obj())){
   tm = TaskMirror::clinit_list_lookup(this);
   GUARANTEE(tm.not_null(), "task mirror must not be null");
   tm = TaskMirror::clinit_list_remove(this);
 }
 GUARANTEE(tm.not_null(), "task mirror must not be null");
 JavaClassObj::Raw mirror = tm().real_java_mirror();
 GUARANTEE(mirror.not_null(), "mirror must not be null");
 if (mirror().status() == JavaClassObj::ERROR_FLAG) {
         return;
 }
 mirror().set_initialized();
 set_task_mirror(&tm);
}
Exemplo n.º 5
0
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());
}