< prev index next >

src/share/vm/prims/jvm.cpp

Print this page




1506   if (found && outer_klass.is_null()) {
1507     // It may be anonymous; try for that.
1508     int encl_method_class_idx = k->enclosing_method_class_index();
1509     if (encl_method_class_idx != 0) {
1510       ok = i_cp->klass_at(encl_method_class_idx, CHECK_NULL);
1511       outer_klass = instanceKlassHandle(thread, ok);
1512       *inner_is_member = false;
1513     }
1514   }
1515 
1516   // If no inner class attribute found for this class.
1517   if (outer_klass.is_null())  return NULL;
1518 
1519   // Throws an exception if outer klass has not declared k as an inner klass
1520   // We need evidence that each klass knows about the other, or else
1521   // the system could allow a spoof of an inner class to gain access rights.
1522   Reflection::check_for_inner_class(outer_klass, k, *inner_is_member, CHECK_NULL);
1523   return outer_klass();
1524 }
1525 


























1526 JVM_ENTRY(jstring, JVM_GetClassSignature(JNIEnv *env, jclass cls))
1527   assert (cls != NULL, "illegal class");
1528   JVMWrapper("JVM_GetClassSignature");
1529   JvmtiVMObjectAllocEventCollector oam;
1530   ResourceMark rm(THREAD);
1531   // Return null for arrays and primatives
1532   if (!java_lang_Class::is_primitive(JNIHandles::resolve(cls))) {
1533     Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve(cls));
1534     if (k->oop_is_instance()) {
1535       Symbol* sym = InstanceKlass::cast(k)->generic_signature();
1536       if (sym == NULL) return NULL;
1537       Handle str = java_lang_String::create_from_symbol(sym, CHECK_NULL);
1538       return (jstring) JNIHandles::make_local(env, str());
1539     }
1540   }
1541   return NULL;
1542 JVM_END
1543 
1544 
1545 JVM_ENTRY(jbyteArray, JVM_GetClassAnnotations(JNIEnv *env, jclass cls))




1506   if (found && outer_klass.is_null()) {
1507     // It may be anonymous; try for that.
1508     int encl_method_class_idx = k->enclosing_method_class_index();
1509     if (encl_method_class_idx != 0) {
1510       ok = i_cp->klass_at(encl_method_class_idx, CHECK_NULL);
1511       outer_klass = instanceKlassHandle(thread, ok);
1512       *inner_is_member = false;
1513     }
1514   }
1515 
1516   // If no inner class attribute found for this class.
1517   if (outer_klass.is_null())  return NULL;
1518 
1519   // Throws an exception if outer klass has not declared k as an inner klass
1520   // We need evidence that each klass knows about the other, or else
1521   // the system could allow a spoof of an inner class to gain access rights.
1522   Reflection::check_for_inner_class(outer_klass, k, *inner_is_member, CHECK_NULL);
1523   return outer_klass();
1524 }
1525 
1526 JVM_ENTRY(jstring, JVM_GetSimpleBinaryName(JNIEnv *env, jclass cls))
1527 {
1528   oop mirror = JNIHandles::resolve_non_null(cls);
1529   if (java_lang_Class::is_primitive(mirror) ||
1530       !java_lang_Class::as_Klass(mirror)->oop_is_instance()) {
1531     return NULL;
1532   }
1533   instanceKlassHandle k(THREAD, InstanceKlass::cast(java_lang_Class::as_Klass(mirror)));
1534   constantPoolHandle i_cp(thread, k->constants());
1535   for (InnerClassesIterator iter(k); !iter.done(); iter.next()) {
1536     int ioff = iter.inner_class_info_index();
1537     int ooff = iter.outer_class_info_index();
1538     int noff = iter.inner_name_index();
1539     if (noff != 0 && ioff != 0 && i_cp->klass_name_at_matches(k, ioff)) {
1540       Klass* inner_klass = i_cp->klass_at(ioff, CHECK_NULL);
1541       if (k() == inner_klass) {
1542         Symbol* name = i_cp->symbol_at(noff);
1543         Handle str = java_lang_String::create_from_symbol(name, CHECK_NULL);
1544         return (jstring) JNIHandles::make_local(env, str());
1545       }
1546     }
1547   }
1548   return NULL;
1549 }
1550 JVM_END
1551 
1552 JVM_ENTRY(jstring, JVM_GetClassSignature(JNIEnv *env, jclass cls))
1553   assert (cls != NULL, "illegal class");
1554   JVMWrapper("JVM_GetClassSignature");
1555   JvmtiVMObjectAllocEventCollector oam;
1556   ResourceMark rm(THREAD);
1557   // Return null for arrays and primatives
1558   if (!java_lang_Class::is_primitive(JNIHandles::resolve(cls))) {
1559     Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve(cls));
1560     if (k->oop_is_instance()) {
1561       Symbol* sym = InstanceKlass::cast(k)->generic_signature();
1562       if (sym == NULL) return NULL;
1563       Handle str = java_lang_String::create_from_symbol(sym, CHECK_NULL);
1564       return (jstring) JNIHandles::make_local(env, str());
1565     }
1566   }
1567   return NULL;
1568 JVM_END
1569 
1570 
1571 JVM_ENTRY(jbyteArray, JVM_GetClassAnnotations(JNIEnv *env, jclass cls))


< prev index next >