694 }
695 }
696
697 // Allow all accesses from jdk/internal/reflect/MagicAccessorImpl subclasses to
698 // succeed trivially.
699 if (current_class->is_subclass_of(SystemDictionary::reflect_MagicAccessorImpl_klass())) {
700 return true;
701 }
702
703 // Check for special relaxations
704 return can_relax_access_check_for(current_class, member_class, classloader_only);
705 }
706
707 bool Reflection::is_same_class_package(const Klass* class1, const Klass* class2) {
708 return InstanceKlass::cast(class1)->is_same_class_package(class2);
709 }
710
711 // Checks that the 'outer' klass has declared 'inner' as being an inner klass. If not,
712 // throw an incompatible class change exception
713 // If inner_is_member, require the inner to be a member of the outer.
714 // If !inner_is_member, require the inner to be unsafe anonymous (a non-member).
715 // Caller is responsible for figuring out in advance which case must be true.
716 void Reflection::check_for_inner_class(const InstanceKlass* outer, const InstanceKlass* inner,
717 bool inner_is_member, TRAPS) {
718 InnerClassesIterator iter(outer);
719 constantPoolHandle cp (THREAD, outer->constants());
720 for (; !iter.done(); iter.next()) {
721 int ioff = iter.inner_class_info_index();
722 int ooff = iter.outer_class_info_index();
723
724 if (inner_is_member && ioff != 0 && ooff != 0) {
725 if (cp->klass_name_at_matches(outer, ooff) &&
726 cp->klass_name_at_matches(inner, ioff)) {
727 Klass* o = cp->klass_at(ooff, CHECK);
728 if (o == outer) {
729 Klass* i = cp->klass_at(ioff, CHECK);
730 if (i == inner) {
731 return;
732 }
733 }
734 }
|
694 }
695 }
696
697 // Allow all accesses from jdk/internal/reflect/MagicAccessorImpl subclasses to
698 // succeed trivially.
699 if (current_class->is_subclass_of(SystemDictionary::reflect_MagicAccessorImpl_klass())) {
700 return true;
701 }
702
703 // Check for special relaxations
704 return can_relax_access_check_for(current_class, member_class, classloader_only);
705 }
706
707 bool Reflection::is_same_class_package(const Klass* class1, const Klass* class2) {
708 return InstanceKlass::cast(class1)->is_same_class_package(class2);
709 }
710
711 // Checks that the 'outer' klass has declared 'inner' as being an inner klass. If not,
712 // throw an incompatible class change exception
713 // If inner_is_member, require the inner to be a member of the outer.
714 // If !inner_is_member, require the inner to be hidden or unsafe anonymous (non-members).
715 // Caller is responsible for figuring out in advance which case must be true.
716 void Reflection::check_for_inner_class(const InstanceKlass* outer, const InstanceKlass* inner,
717 bool inner_is_member, TRAPS) {
718 InnerClassesIterator iter(outer);
719 constantPoolHandle cp (THREAD, outer->constants());
720 for (; !iter.done(); iter.next()) {
721 int ioff = iter.inner_class_info_index();
722 int ooff = iter.outer_class_info_index();
723
724 if (inner_is_member && ioff != 0 && ooff != 0) {
725 if (cp->klass_name_at_matches(outer, ooff) &&
726 cp->klass_name_at_matches(inner, ioff)) {
727 Klass* o = cp->klass_at(ooff, CHECK);
728 if (o == outer) {
729 Klass* i = cp->klass_at(ioff, CHECK);
730 if (i == inner) {
731 return;
732 }
733 }
734 }
|