< prev index next >

src/hotspot/share/runtime/reflection.cpp

Print this page




 663   //
 664   // "resolved_class" is the runtime type of "field_class". Sometimes we don't
 665   // need this distinction (e.g. if all we have is the runtime type, or during
 666   // class file parsing when we only care about the static type); in that case
 667   // callers should ensure that resolved_class == field_class.
 668   //
 669   if ((current_class == NULL) ||
 670       (current_class == field_class) ||
 671       access.is_public()) {
 672     return true;
 673   }
 674 
 675   const Klass* host_class = current_class;
 676   if (host_class->is_instance_klass() &&
 677       InstanceKlass::cast(host_class)->is_anonymous()) {
 678     host_class = InstanceKlass::cast(host_class)->host_klass();
 679     assert(host_class != NULL, "Anonymous class has null host class");
 680     assert(!(host_class->is_instance_klass() &&
 681            InstanceKlass::cast(host_class)->is_anonymous()),
 682            "host_class should not be anonymous");
 683 
 684     // For Minimal Value Types check if the field class is a value type
 685     // if so check if it has a Value Capable Class that is the host class,
 686     // if so use the field class the host class
 687     if (field_class->is_value() &&
 688         InstanceKlass::cast(field_class)->get_vcc_klass() == host_class) {
 689       host_class = field_class;
 690     }
 691   }
 692   if (host_class == field_class) {
 693     return true;
 694   }
 695 
 696   if (access.is_protected()) {
 697     if (!protected_restriction) {
 698       // See if current_class (or outermost host class) is a subclass of field_class
 699       // An interface may not access protected members of j.l.Object
 700       if (!host_class->is_interface() && host_class->is_subclass_of(field_class)) {
 701         if (access.is_static() || // static fields are ok, see 6622385
 702             current_class == resolved_class ||
 703             field_class == resolved_class ||
 704             host_class->is_subclass_of(resolved_class) ||
 705             resolved_class->is_subclass_of(host_class)) {
 706           return true;
 707         }
 708       }
 709     }
 710   }




 663   //
 664   // "resolved_class" is the runtime type of "field_class". Sometimes we don't
 665   // need this distinction (e.g. if all we have is the runtime type, or during
 666   // class file parsing when we only care about the static type); in that case
 667   // callers should ensure that resolved_class == field_class.
 668   //
 669   if ((current_class == NULL) ||
 670       (current_class == field_class) ||
 671       access.is_public()) {
 672     return true;
 673   }
 674 
 675   const Klass* host_class = current_class;
 676   if (host_class->is_instance_klass() &&
 677       InstanceKlass::cast(host_class)->is_anonymous()) {
 678     host_class = InstanceKlass::cast(host_class)->host_klass();
 679     assert(host_class != NULL, "Anonymous class has null host class");
 680     assert(!(host_class->is_instance_klass() &&
 681            InstanceKlass::cast(host_class)->is_anonymous()),
 682            "host_class should not be anonymous");








 683   }
 684   if (host_class == field_class) {
 685     return true;
 686   }
 687 
 688   if (access.is_protected()) {
 689     if (!protected_restriction) {
 690       // See if current_class (or outermost host class) is a subclass of field_class
 691       // An interface may not access protected members of j.l.Object
 692       if (!host_class->is_interface() && host_class->is_subclass_of(field_class)) {
 693         if (access.is_static() || // static fields are ok, see 6622385
 694             current_class == resolved_class ||
 695             field_class == resolved_class ||
 696             host_class->is_subclass_of(resolved_class) ||
 697             resolved_class->is_subclass_of(host_class)) {
 698           return true;
 699         }
 700       }
 701     }
 702   }


< prev index next >