< prev index next >

src/hotspot/share/runtime/reflection.cpp

Print this page




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




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


< prev index next >