339 HandleMark hm(THREAD); |
339 HandleMark hm(THREAD); |
340 Handle key_str = java_lang_String::create_from_platform_dependent_str(key, CHECK); |
340 Handle key_str = java_lang_String::create_from_platform_dependent_str(key, CHECK); |
341 Handle value_str = java_lang_String::create_from_platform_dependent_str((value != NULL ? value : ""), CHECK); |
341 Handle value_str = java_lang_String::create_from_platform_dependent_str((value != NULL ? value : ""), CHECK); |
342 JavaCalls::call_virtual(&r, |
342 JavaCalls::call_virtual(&r, |
343 props, |
343 props, |
344 KlassHandle(THREAD, SystemDictionary::Properties_klass()), |
344 SystemDictionary::Properties_klass(), |
345 vmSymbols::put_name(), |
345 vmSymbols::put_name(), |
346 vmSymbols::object_object_object_signature(), |
346 vmSymbols::object_object_object_signature(), |
347 key_str, |
347 key_str, |
348 value_str, |
348 value_str, |
349 THREAD); |
349 THREAD); |
619 |
619 |
620 |
620 |
621 JVM_ENTRY(jobject, JVM_Clone(JNIEnv* env, jobject handle)) |
621 JVM_ENTRY(jobject, JVM_Clone(JNIEnv* env, jobject handle)) |
622 JVMWrapper("JVM_Clone"); |
622 JVMWrapper("JVM_Clone"); |
623 Handle obj(THREAD, JNIHandles::resolve_non_null(handle)); |
623 Handle obj(THREAD, JNIHandles::resolve_non_null(handle)); |
624 const KlassHandle klass (THREAD, obj->klass()); |
624 Klass* klass = obj->klass(); |
625 JvmtiVMObjectAllocEventCollector oam; |
625 JvmtiVMObjectAllocEventCollector oam; |
626 |
626 |
627 #ifdef ASSERT |
627 #ifdef ASSERT |
628 // Just checking that the cloneable flag is set correct |
628 // Just checking that the cloneable flag is set correct |
629 if (obj->is_array()) { |
629 if (obj->is_array()) { |
995 CHECK_NULL); |
995 CHECK_NULL); |
996 #if INCLUDE_CDS |
996 #if INCLUDE_CDS |
997 if (k == NULL) { |
997 if (k == NULL) { |
998 // If the class is not already loaded, try to see if it's in the shared |
998 // If the class is not already loaded, try to see if it's in the shared |
999 // archive for the current classloader (h_loader). |
999 // archive for the current classloader (h_loader). |
1000 instanceKlassHandle ik = SystemDictionaryShared::find_or_load_shared_class( |
1000 k = SystemDictionaryShared::find_or_load_shared_class(klass_name, h_loader, CHECK_NULL); |
1001 klass_name, h_loader, CHECK_NULL); |
|
1002 k = ik(); |
|
1003 } |
1001 } |
1004 #endif |
1002 #endif |
1005 return (k == NULL) ? NULL : |
1003 return (k == NULL) ? NULL : |
1006 (jclass) JNIHandles::make_local(env, k->java_mirror()); |
1004 (jclass) JNIHandles::make_local(env, k->java_mirror()); |
1007 JVM_END |
1005 JVM_END |
1075 // Primitive objects does not have any interfaces |
1073 // Primitive objects does not have any interfaces |
1076 objArrayOop r = oopFactory::new_objArray(SystemDictionary::Class_klass(), 0, CHECK_NULL); |
1074 objArrayOop r = oopFactory::new_objArray(SystemDictionary::Class_klass(), 0, CHECK_NULL); |
1077 return (jobjectArray) JNIHandles::make_local(env, r); |
1075 return (jobjectArray) JNIHandles::make_local(env, r); |
1078 } |
1076 } |
1079 |
1077 |
1080 KlassHandle klass(thread, java_lang_Class::as_Klass(mirror)); |
1078 Klass* klass = java_lang_Class::as_Klass(mirror); |
1081 // Figure size of result array |
1079 // Figure size of result array |
1082 int size; |
1080 int size; |
1083 if (klass->is_instance_klass()) { |
1081 if (klass->is_instance_klass()) { |
1084 size = InstanceKlass::cast(klass())->local_interfaces()->length(); |
1082 size = InstanceKlass::cast(klass)->local_interfaces()->length(); |
1085 } else { |
1083 } else { |
1086 assert(klass->is_objArray_klass() || klass->is_typeArray_klass(), "Illegal mirror klass"); |
1084 assert(klass->is_objArray_klass() || klass->is_typeArray_klass(), "Illegal mirror klass"); |
1087 size = 2; |
1085 size = 2; |
1088 } |
1086 } |
1089 |
1087 |
1092 objArrayHandle result (THREAD, r); |
1090 objArrayHandle result (THREAD, r); |
1093 // Fill in result |
1091 // Fill in result |
1094 if (klass->is_instance_klass()) { |
1092 if (klass->is_instance_klass()) { |
1095 // Regular instance klass, fill in all local interfaces |
1093 // Regular instance klass, fill in all local interfaces |
1096 for (int index = 0; index < size; index++) { |
1094 for (int index = 0; index < size; index++) { |
1097 Klass* k = InstanceKlass::cast(klass())->local_interfaces()->at(index); |
1095 Klass* k = InstanceKlass::cast(klass)->local_interfaces()->at(index); |
1098 result->obj_at_put(index, k->java_mirror()); |
1096 result->obj_at_put(index, k->java_mirror()); |
1099 } |
1097 } |
1100 } else { |
1098 } else { |
1101 // All arrays implement java.lang.Cloneable and java.io.Serializable |
1099 // All arrays implement java.lang.Cloneable and java.io.Serializable |
1102 result->obj_at_put(0, SystemDictionary::Cloneable_klass()->java_mirror()); |
1100 result->obj_at_put(0, SystemDictionary::Cloneable_klass()->java_mirror()); |
1176 oop pd = java_lang_Class::protection_domain(JNIHandles::resolve(cls)); |
1174 oop pd = java_lang_Class::protection_domain(JNIHandles::resolve(cls)); |
1177 return (jobject) JNIHandles::make_local(env, pd); |
1175 return (jobject) JNIHandles::make_local(env, pd); |
1178 JVM_END |
1176 JVM_END |
1179 |
1177 |
1180 |
1178 |
1181 static bool is_authorized(Handle context, instanceKlassHandle klass, TRAPS) { |
1179 static bool is_authorized(Handle context, InstanceKlass* klass, TRAPS) { |
1182 // If there is a security manager and protection domain, check the access |
1180 // If there is a security manager and protection domain, check the access |
1183 // in the protection domain, otherwise it is authorized. |
1181 // in the protection domain, otherwise it is authorized. |
1184 if (java_lang_System::has_security_manager()) { |
1182 if (java_lang_System::has_security_manager()) { |
1185 |
1183 |
1186 // For bootstrapping, if pd implies method isn't in the JDK, allow |
1184 // For bootstrapping, if pd implies method isn't in the JDK, allow |
1216 oop create_dummy_access_control_context(TRAPS) { |
1214 oop create_dummy_access_control_context(TRAPS) { |
1217 InstanceKlass* pd_klass = SystemDictionary::ProtectionDomain_klass(); |
1215 InstanceKlass* pd_klass = SystemDictionary::ProtectionDomain_klass(); |
1218 Handle obj = pd_klass->allocate_instance_handle(CHECK_NULL); |
1216 Handle obj = pd_klass->allocate_instance_handle(CHECK_NULL); |
1219 // Call constructor ProtectionDomain(null, null); |
1217 // Call constructor ProtectionDomain(null, null); |
1220 JavaValue result(T_VOID); |
1218 JavaValue result(T_VOID); |
1221 JavaCalls::call_special(&result, obj, KlassHandle(THREAD, pd_klass), |
1219 JavaCalls::call_special(&result, obj, pd_klass, |
1222 vmSymbols::object_initializer_name(), |
1220 vmSymbols::object_initializer_name(), |
1223 vmSymbols::codesource_permissioncollection_signature(), |
1221 vmSymbols::codesource_permissioncollection_signature(), |
1224 Handle(), Handle(), CHECK_NULL); |
1222 Handle(), Handle(), CHECK_NULL); |
1225 |
1223 |
1226 // new ProtectionDomain[] {pd}; |
1224 // new ProtectionDomain[] {pd}; |
1247 if (vfst.at_end()) { |
1245 if (vfst.at_end()) { |
1248 THROW_MSG_0(vmSymbols::java_lang_InternalError(), "no caller?"); |
1246 THROW_MSG_0(vmSymbols::java_lang_InternalError(), "no caller?"); |
1249 } |
1247 } |
1250 |
1248 |
1251 Method* method = vfst.method(); |
1249 Method* method = vfst.method(); |
1252 instanceKlassHandle klass (THREAD, method->method_holder()); |
1250 InstanceKlass* klass = method->method_holder(); |
1253 |
1251 |
1254 // Check that action object understands "Object run()" |
1252 // Check that action object understands "Object run()" |
1255 Handle h_context; |
1253 Handle h_context; |
1256 if (context != NULL) { |
1254 if (context != NULL) { |
1257 h_context = Handle(THREAD, JNIHandles::resolve(context)); |
1255 h_context = Handle(THREAD, JNIHandles::resolve(context)); |
1450 ! java_lang_Class::as_Klass(JNIHandles::resolve_non_null(ofClass))->is_instance_klass()) { |
1448 ! java_lang_Class::as_Klass(JNIHandles::resolve_non_null(ofClass))->is_instance_klass()) { |
1451 oop result = oopFactory::new_objArray(SystemDictionary::Class_klass(), 0, CHECK_NULL); |
1449 oop result = oopFactory::new_objArray(SystemDictionary::Class_klass(), 0, CHECK_NULL); |
1452 return (jobjectArray)JNIHandles::make_local(env, result); |
1450 return (jobjectArray)JNIHandles::make_local(env, result); |
1453 } |
1451 } |
1454 |
1452 |
1455 instanceKlassHandle k(thread, java_lang_Class::as_Klass(JNIHandles::resolve_non_null(ofClass))); |
1453 InstanceKlass* k = InstanceKlass::cast(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(ofClass))); |
1456 InnerClassesIterator iter(k); |
1454 InnerClassesIterator iter(k); |
1457 |
1455 |
1458 if (iter.length() == 0) { |
1456 if (iter.length() == 0) { |
1459 // Neither an inner nor outer class |
1457 // Neither an inner nor outer class |
1460 oop result = oopFactory::new_objArray(SystemDictionary::Class_klass(), 0, CHECK_NULL); |
1458 oop result = oopFactory::new_objArray(SystemDictionary::Class_klass(), 0, CHECK_NULL); |
1477 if (ioff != 0 && ooff != 0) { |
1475 if (ioff != 0 && ooff != 0) { |
1478 // Check to see if the name matches the class we're looking for |
1476 // Check to see if the name matches the class we're looking for |
1479 // before attempting to find the class. |
1477 // before attempting to find the class. |
1480 if (cp->klass_name_at_matches(k, ooff)) { |
1478 if (cp->klass_name_at_matches(k, ooff)) { |
1481 Klass* outer_klass = cp->klass_at(ooff, CHECK_NULL); |
1479 Klass* outer_klass = cp->klass_at(ooff, CHECK_NULL); |
1482 if (outer_klass == k()) { |
1480 if (outer_klass == k) { |
1483 Klass* ik = cp->klass_at(ioff, CHECK_NULL); |
1481 Klass* ik = cp->klass_at(ioff, CHECK_NULL); |
1484 instanceKlassHandle inner_klass (THREAD, ik); |
1482 InstanceKlass* inner_klass = InstanceKlass::cast(ik); |
1485 |
1483 |
1486 // Throws an exception if outer klass has not declared k as |
1484 // Throws an exception if outer klass has not declared k as |
1487 // an inner klass |
1485 // an inner klass |
1488 Reflection::check_for_inner_class(k, inner_klass, true, CHECK_NULL); |
1486 Reflection::check_for_inner_class(k, inner_klass, true, CHECK_NULL); |
1489 |
1487 |
1530 oop mirror = JNIHandles::resolve_non_null(cls); |
1528 oop mirror = JNIHandles::resolve_non_null(cls); |
1531 if (java_lang_Class::is_primitive(mirror) || |
1529 if (java_lang_Class::is_primitive(mirror) || |
1532 !java_lang_Class::as_Klass(mirror)->is_instance_klass()) { |
1530 !java_lang_Class::as_Klass(mirror)->is_instance_klass()) { |
1533 return NULL; |
1531 return NULL; |
1534 } |
1532 } |
1535 instanceKlassHandle k(THREAD, InstanceKlass::cast(java_lang_Class::as_Klass(mirror))); |
1533 InstanceKlass* k = InstanceKlass::cast(java_lang_Class::as_Klass(mirror)); |
1536 int ooff = 0, noff = 0; |
1534 int ooff = 0, noff = 0; |
1537 if (InstanceKlass::find_inner_classes_attr(k, &ooff, &noff, THREAD)) { |
1535 if (InstanceKlass::find_inner_classes_attr(k, &ooff, &noff, THREAD)) { |
1538 if (noff != 0) { |
1536 if (noff != 0) { |
1539 constantPoolHandle i_cp(thread, k->constants()); |
1537 constantPoolHandle i_cp(thread, k->constants()); |
1540 Symbol* name = i_cp->symbol_at(noff); |
1538 Symbol* name = i_cp->symbol_at(noff); |
1588 oop mirror = java_lang_reflect_Field::clazz(reflected); |
1586 oop mirror = java_lang_reflect_Field::clazz(reflected); |
1589 Klass* k = java_lang_Class::as_Klass(mirror); |
1587 Klass* k = java_lang_Class::as_Klass(mirror); |
1590 int slot = java_lang_reflect_Field::slot(reflected); |
1588 int slot = java_lang_reflect_Field::slot(reflected); |
1591 int modifiers = java_lang_reflect_Field::modifiers(reflected); |
1589 int modifiers = java_lang_reflect_Field::modifiers(reflected); |
1592 |
1590 |
1593 KlassHandle kh(THREAD, k); |
1591 InstanceKlass* ik = InstanceKlass::cast(k); |
1594 intptr_t offset = InstanceKlass::cast(kh())->field_offset(slot); |
1592 intptr_t offset = ik->field_offset(slot); |
1595 |
1593 |
1596 if (modifiers & JVM_ACC_STATIC) { |
1594 if (modifiers & JVM_ACC_STATIC) { |
1597 // for static fields we only look in the current class |
1595 // for static fields we only look in the current class |
1598 if (!InstanceKlass::cast(kh())->find_local_field_from_offset(offset, true, &fd)) { |
1596 if (!ik->find_local_field_from_offset(offset, true, &fd)) { |
1599 assert(false, "cannot find static field"); |
1597 assert(false, "cannot find static field"); |
1600 return false; |
1598 return false; |
1601 } |
1599 } |
1602 } else { |
1600 } else { |
1603 // for instance fields we start with the current class and work |
1601 // for instance fields we start with the current class and work |
1604 // our way up through the superclass chain |
1602 // our way up through the superclass chain |
1605 if (!InstanceKlass::cast(kh())->find_field_from_offset(offset, false, &fd)) { |
1603 if (!ik->find_field_from_offset(offset, false, &fd)) { |
1606 assert(false, "cannot find instance field"); |
1604 assert(false, "cannot find instance field"); |
1607 return false; |
1605 return false; |
1608 } |
1606 } |
1609 } |
1607 } |
1610 return true; |
1608 return true; |
1755 // Return empty array |
1753 // Return empty array |
1756 oop res = oopFactory::new_objArray(SystemDictionary::reflect_Field_klass(), 0, CHECK_NULL); |
1754 oop res = oopFactory::new_objArray(SystemDictionary::reflect_Field_klass(), 0, CHECK_NULL); |
1757 return (jobjectArray) JNIHandles::make_local(env, res); |
1755 return (jobjectArray) JNIHandles::make_local(env, res); |
1758 } |
1756 } |
1759 |
1757 |
1760 instanceKlassHandle k(THREAD, java_lang_Class::as_Klass(JNIHandles::resolve_non_null(ofClass))); |
1758 InstanceKlass* k = InstanceKlass::cast(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(ofClass))); |
1761 constantPoolHandle cp(THREAD, k->constants()); |
1759 constantPoolHandle cp(THREAD, k->constants()); |
1762 |
1760 |
1763 // Ensure class is linked |
1761 // Ensure class is linked |
1764 k->link_class(CHECK_NULL); |
1762 k->link_class(CHECK_NULL); |
1765 |
1763 |
1766 // Allocate result |
1764 // Allocate result |
1767 int num_fields; |
1765 int num_fields; |
1768 |
1766 |
1769 if (publicOnly) { |
1767 if (publicOnly) { |
1770 num_fields = 0; |
1768 num_fields = 0; |
1771 for (JavaFieldStream fs(k()); !fs.done(); fs.next()) { |
1769 for (JavaFieldStream fs(k); !fs.done(); fs.next()) { |
1772 if (fs.access_flags().is_public()) ++num_fields; |
1770 if (fs.access_flags().is_public()) ++num_fields; |
1773 } |
1771 } |
1774 } else { |
1772 } else { |
1775 num_fields = k->java_fields_count(); |
1773 num_fields = k->java_fields_count(); |
1776 } |
1774 } |
1780 |
1778 |
1781 int out_idx = 0; |
1779 int out_idx = 0; |
1782 fieldDescriptor fd; |
1780 fieldDescriptor fd; |
1783 for (JavaFieldStream fs(k); !fs.done(); fs.next()) { |
1781 for (JavaFieldStream fs(k); !fs.done(); fs.next()) { |
1784 if (!publicOnly || fs.access_flags().is_public()) { |
1782 if (!publicOnly || fs.access_flags().is_public()) { |
1785 fd.reinitialize(k(), fs.index()); |
1783 fd.reinitialize(k, fs.index()); |
1786 oop field = Reflection::new_field(&fd, CHECK_NULL); |
1784 oop field = Reflection::new_field(&fd, CHECK_NULL); |
1787 result->obj_at_put(out_idx, field); |
1785 result->obj_at_put(out_idx, field); |
1788 ++out_idx; |
1786 ++out_idx; |
1789 } |
1787 } |
1790 } |
1788 } |
1815 // Return empty array |
1813 // Return empty array |
1816 oop res = oopFactory::new_objArray(klass, 0, CHECK_NULL); |
1814 oop res = oopFactory::new_objArray(klass, 0, CHECK_NULL); |
1817 return (jobjectArray) JNIHandles::make_local(env, res); |
1815 return (jobjectArray) JNIHandles::make_local(env, res); |
1818 } |
1816 } |
1819 |
1817 |
1820 instanceKlassHandle k(THREAD, java_lang_Class::as_Klass(JNIHandles::resolve_non_null(ofClass))); |
1818 InstanceKlass* k = InstanceKlass::cast(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(ofClass))); |
1821 |
1819 |
1822 // Ensure class is linked |
1820 // Ensure class is linked |
1823 k->link_class(CHECK_NULL); |
1821 k->link_class(CHECK_NULL); |
1824 |
1822 |
1825 Array<Method*>* methods = k->methods(); |
1823 Array<Method*>* methods = k->methods(); |
1911 |
1909 |
1912 // Return null for primitives and arrays |
1910 // Return null for primitives and arrays |
1913 if (!java_lang_Class::is_primitive(JNIHandles::resolve_non_null(cls))) { |
1911 if (!java_lang_Class::is_primitive(JNIHandles::resolve_non_null(cls))) { |
1914 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
1912 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
1915 if (k->is_instance_klass()) { |
1913 if (k->is_instance_klass()) { |
1916 instanceKlassHandle k_h(THREAD, k); |
1914 InstanceKlass* k_h = InstanceKlass::cast(k); |
1917 Handle jcp = reflect_ConstantPool::create(CHECK_NULL); |
1915 Handle jcp = reflect_ConstantPool::create(CHECK_NULL); |
1918 reflect_ConstantPool::set_cp(jcp(), k_h->constants()); |
1916 reflect_ConstantPool::set_cp(jcp(), k_h->constants()); |
1919 return JNIHandles::make_local(jcp()); |
1917 return JNIHandles::make_local(jcp()); |
1920 } |
1918 } |
1921 } |
1919 } |
1973 k_o = cp->klass_at(klass_ref, CHECK_NULL); |
1971 k_o = cp->klass_at(klass_ref, CHECK_NULL); |
1974 } else { |
1972 } else { |
1975 k_o = ConstantPool::klass_at_if_loaded(cp, klass_ref); |
1973 k_o = ConstantPool::klass_at_if_loaded(cp, klass_ref); |
1976 if (k_o == NULL) return NULL; |
1974 if (k_o == NULL) return NULL; |
1977 } |
1975 } |
1978 instanceKlassHandle k(THREAD, k_o); |
1976 InstanceKlass* k = InstanceKlass::cast(k_o); |
1979 Symbol* name = cp->uncached_name_ref_at(index); |
1977 Symbol* name = cp->uncached_name_ref_at(index); |
1980 Symbol* sig = cp->uncached_signature_ref_at(index); |
1978 Symbol* sig = cp->uncached_signature_ref_at(index); |
1981 methodHandle m (THREAD, k->find_method(name, sig)); |
1979 methodHandle m (THREAD, k->find_method(name, sig)); |
1982 if (m.is_null()) { |
1980 if (m.is_null()) { |
1983 THROW_MSG_0(vmSymbols::java_lang_RuntimeException(), "Unable to look up method in target class"); |
1981 THROW_MSG_0(vmSymbols::java_lang_RuntimeException(), "Unable to look up method in target class"); |
2024 k_o = cp->klass_at(klass_ref, CHECK_NULL); |
2022 k_o = cp->klass_at(klass_ref, CHECK_NULL); |
2025 } else { |
2023 } else { |
2026 k_o = ConstantPool::klass_at_if_loaded(cp, klass_ref); |
2024 k_o = ConstantPool::klass_at_if_loaded(cp, klass_ref); |
2027 if (k_o == NULL) return NULL; |
2025 if (k_o == NULL) return NULL; |
2028 } |
2026 } |
2029 instanceKlassHandle k(THREAD, k_o); |
2027 InstanceKlass* k = InstanceKlass::cast(k_o); |
2030 Symbol* name = cp->uncached_name_ref_at(index); |
2028 Symbol* name = cp->uncached_name_ref_at(index); |
2031 Symbol* sig = cp->uncached_signature_ref_at(index); |
2029 Symbol* sig = cp->uncached_signature_ref_at(index); |
2032 fieldDescriptor fd; |
2030 fieldDescriptor fd; |
2033 Klass* target_klass = k->find_field(name, sig, &fd); |
2031 Klass* target_klass = k->find_field(name, sig, &fd); |
2034 if (target_klass == NULL) { |
2032 if (target_klass == NULL) { |
2614 ConstantPool* cp_called = InstanceKlass::cast(k_called)->constants(); |
2612 ConstantPool* cp_called = InstanceKlass::cast(k_called)->constants(); |
2615 switch (cp->tag_at(cp_index).value()) { |
2613 switch (cp->tag_at(cp_index).value()) { |
2616 case JVM_CONSTANT_Fieldref: { |
2614 case JVM_CONSTANT_Fieldref: { |
2617 Symbol* name = cp->uncached_name_ref_at(cp_index); |
2615 Symbol* name = cp->uncached_name_ref_at(cp_index); |
2618 Symbol* signature = cp->uncached_signature_ref_at(cp_index); |
2616 Symbol* signature = cp->uncached_signature_ref_at(cp_index); |
2619 for (JavaFieldStream fs(k_called); !fs.done(); fs.next()) { |
2617 InstanceKlass* ik = InstanceKlass::cast(k_called); |
|
2618 for (JavaFieldStream fs(ik); !fs.done(); fs.next()) { |
2620 if (fs.name() == name && fs.signature() == signature) { |
2619 if (fs.name() == name && fs.signature() == signature) { |
2621 return fs.access_flags().as_short() & JVM_RECOGNIZED_FIELD_MODIFIERS; |
2620 return fs.access_flags().as_short() & JVM_RECOGNIZED_FIELD_MODIFIERS; |
2622 } |
2621 } |
2623 } |
2622 } |
2624 return -1; |
2623 return -1; |
2768 HandleMark hm(THREAD); |
2767 HandleMark hm(THREAD); |
2769 Handle obj(THREAD, thread->threadObj()); |
2768 Handle obj(THREAD, thread->threadObj()); |
2770 JavaValue result(T_VOID); |
2769 JavaValue result(T_VOID); |
2771 JavaCalls::call_virtual(&result, |
2770 JavaCalls::call_virtual(&result, |
2772 obj, |
2771 obj, |
2773 KlassHandle(THREAD, SystemDictionary::Thread_klass()), |
2772 SystemDictionary::Thread_klass(), |
2774 vmSymbols::run_method_name(), |
2773 vmSymbols::run_method_name(), |
2775 vmSymbols::void_method_signature(), |
2774 vmSymbols::void_method_signature(), |
2776 THREAD); |
2775 THREAD); |
2777 } |
2776 } |
2778 |
2777 |
3224 THROW_MSG_NULL(vmSymbols::java_lang_InternalError(), "JVM_GetClassContext must only be called from SecurityManager.getClassContext"); |
3223 THROW_MSG_NULL(vmSymbols::java_lang_InternalError(), "JVM_GetClassContext must only be called from SecurityManager.getClassContext"); |
3225 } |
3224 } |
3226 } |
3225 } |
3227 |
3226 |
3228 // Collect method holders |
3227 // Collect method holders |
3229 GrowableArray<KlassHandle>* klass_array = new GrowableArray<KlassHandle>(); |
3228 GrowableArray<Klass*>* klass_array = new GrowableArray<Klass*>(); |
3230 for (; !vfst.at_end(); vfst.security_next()) { |
3229 for (; !vfst.at_end(); vfst.security_next()) { |
3231 Method* m = vfst.method(); |
3230 Method* m = vfst.method(); |
3232 // Native frames are not returned |
3231 // Native frames are not returned |
3233 if (!m->is_ignored_by_security_stack_walk() && !m->is_native()) { |
3232 if (!m->is_ignored_by_security_stack_walk() && !m->is_native()) { |
3234 Klass* holder = m->method_holder(); |
3233 Klass* holder = m->method_holder(); |
3591 // the checkPackageAccess relative to the initiating class loader via the |
3590 // the checkPackageAccess relative to the initiating class loader via the |
3592 // protection_domain. The protection_domain is passed as NULL by the java code |
3591 // protection_domain. The protection_domain is passed as NULL by the java code |
3593 // if there is no security manager in 3-arg Class.forName(). |
3592 // if there is no security manager in 3-arg Class.forName(). |
3594 Klass* klass = SystemDictionary::resolve_or_fail(name, loader, protection_domain, throwError != 0, CHECK_NULL); |
3593 Klass* klass = SystemDictionary::resolve_or_fail(name, loader, protection_domain, throwError != 0, CHECK_NULL); |
3595 |
3594 |
3596 KlassHandle klass_handle(THREAD, klass); |
|
3597 // Check if we should initialize the class |
3595 // Check if we should initialize the class |
3598 if (init && klass_handle->is_instance_klass()) { |
3596 if (init && klass->is_instance_klass()) { |
3599 klass_handle->initialize(CHECK_NULL); |
3597 klass->initialize(CHECK_NULL); |
3600 } |
3598 } |
3601 return (jclass) JNIHandles::make_local(env, klass_handle->java_mirror()); |
3599 return (jclass) JNIHandles::make_local(env, klass->java_mirror()); |
3602 } |
3600 } |
3603 |
3601 |
3604 |
3602 |
3605 // Method /////////////////////////////////////////////////////////////////////////////////////////// |
3603 // Method /////////////////////////////////////////////////////////////////////////////////////////// |
3606 |
3604 |
3744 } |
3742 } |
3745 Klass* k = java_lang_Class::as_Klass(mirror()); |
3743 Klass* k = java_lang_Class::as_Klass(mirror()); |
3746 if (!k->is_instance_klass()) { |
3744 if (!k->is_instance_klass()) { |
3747 return NULL; |
3745 return NULL; |
3748 } |
3746 } |
3749 instanceKlassHandle ik_h(THREAD, k); |
3747 InstanceKlass* ik = InstanceKlass::cast(k); |
3750 int encl_method_class_idx = ik_h->enclosing_method_class_index(); |
3748 int encl_method_class_idx = ik->enclosing_method_class_index(); |
3751 if (encl_method_class_idx == 0) { |
3749 if (encl_method_class_idx == 0) { |
3752 return NULL; |
3750 return NULL; |
3753 } |
3751 } |
3754 objArrayOop dest_o = oopFactory::new_objArray(SystemDictionary::Object_klass(), 3, CHECK_NULL); |
3752 objArrayOop dest_o = oopFactory::new_objArray(SystemDictionary::Object_klass(), 3, CHECK_NULL); |
3755 objArrayHandle dest(THREAD, dest_o); |
3753 objArrayHandle dest(THREAD, dest_o); |
3756 Klass* enc_k = ik_h->constants()->klass_at(encl_method_class_idx, CHECK_NULL); |
3754 Klass* enc_k = ik->constants()->klass_at(encl_method_class_idx, CHECK_NULL); |
3757 dest->obj_at_put(0, enc_k->java_mirror()); |
3755 dest->obj_at_put(0, enc_k->java_mirror()); |
3758 int encl_method_method_idx = ik_h->enclosing_method_method_index(); |
3756 int encl_method_method_idx = ik->enclosing_method_method_index(); |
3759 if (encl_method_method_idx != 0) { |
3757 if (encl_method_method_idx != 0) { |
3760 Symbol* sym = ik_h->constants()->symbol_at( |
3758 Symbol* sym = ik->constants()->symbol_at( |
3761 extract_low_short_from_int( |
3759 extract_low_short_from_int( |
3762 ik_h->constants()->name_and_type_at(encl_method_method_idx))); |
3760 ik->constants()->name_and_type_at(encl_method_method_idx))); |
3763 Handle str = java_lang_String::create_from_symbol(sym, CHECK_NULL); |
3761 Handle str = java_lang_String::create_from_symbol(sym, CHECK_NULL); |
3764 dest->obj_at_put(1, str()); |
3762 dest->obj_at_put(1, str()); |
3765 sym = ik_h->constants()->symbol_at( |
3763 sym = ik->constants()->symbol_at( |
3766 extract_high_short_from_int( |
3764 extract_high_short_from_int( |
3767 ik_h->constants()->name_and_type_at(encl_method_method_idx))); |
3765 ik->constants()->name_and_type_at(encl_method_method_idx))); |
3768 str = java_lang_String::create_from_symbol(sym, CHECK_NULL); |
3766 str = java_lang_String::create_from_symbol(sym, CHECK_NULL); |
3769 dest->obj_at_put(2, str()); |
3767 dest->obj_at_put(2, str()); |
3770 } |
3768 } |
3771 return (jobjectArray) JNIHandles::make_local(dest()); |
3769 return (jobjectArray) JNIHandles::make_local(dest()); |
3772 } |
3770 } |
3797 char** vm_flags = Arguments::jvm_flags_array(); |
3795 char** vm_flags = Arguments::jvm_flags_array(); |
3798 char** vm_args = Arguments::jvm_args_array(); |
3796 char** vm_args = Arguments::jvm_args_array(); |
3799 int num_flags = Arguments::num_jvm_flags(); |
3797 int num_flags = Arguments::num_jvm_flags(); |
3800 int num_args = Arguments::num_jvm_args(); |
3798 int num_args = Arguments::num_jvm_args(); |
3801 |
3799 |
3802 instanceKlassHandle ik (THREAD, SystemDictionary::String_klass()); |
3800 InstanceKlass* ik = SystemDictionary::String_klass(); |
3803 objArrayOop r = oopFactory::new_objArray(ik(), num_args + num_flags, CHECK_NULL); |
3801 objArrayOop r = oopFactory::new_objArray(ik, num_args + num_flags, CHECK_NULL); |
3804 objArrayHandle result_h(THREAD, r); |
3802 objArrayHandle result_h(THREAD, r); |
3805 |
3803 |
3806 int index = 0; |
3804 int index = 0; |
3807 for (int j = 0; j < num_flags; j++, index++) { |
3805 for (int j = 0; j < num_flags; j++, index++) { |
3808 Handle h = java_lang_String::create_from_platform_dependent_str(vm_flags[j], CHECK_NULL); |
3806 Handle h = java_lang_String::create_from_platform_dependent_str(vm_flags[j], CHECK_NULL); |