hotspot/src/share/vm/classfile/dictionary.hpp
changeset 47098 e704f55561c3
parent 46746 ea379ebb9447
child 47103 a993ec29ec75
equal deleted inserted replaced
47097:e43050e1b17f 47098:e704f55561c3
    27 
    27 
    28 #include "classfile/protectionDomainCache.hpp"
    28 #include "classfile/protectionDomainCache.hpp"
    29 #include "classfile/systemDictionary.hpp"
    29 #include "classfile/systemDictionary.hpp"
    30 #include "oops/instanceKlass.hpp"
    30 #include "oops/instanceKlass.hpp"
    31 #include "oops/oop.hpp"
    31 #include "oops/oop.hpp"
       
    32 #include "runtime/orderAccess.hpp"
    32 #include "utilities/hashtable.hpp"
    33 #include "utilities/hashtable.hpp"
    33 #include "utilities/ostream.hpp"
    34 #include "utilities/ostream.hpp"
    34 
    35 
    35 class DictionaryEntry;
    36 class DictionaryEntry;
    36 class BoolObjectClosure;
    37 class BoolObjectClosure;
   132   //
   133   //
   133   // The usage of the PD set can be seen in SystemDictionary::validate_protection_domain()
   134   // The usage of the PD set can be seen in SystemDictionary::validate_protection_domain()
   134   // It is essentially a cache to avoid repeated Java up-calls to
   135   // It is essentially a cache to avoid repeated Java up-calls to
   135   // ClassLoader.checkPackageAccess().
   136   // ClassLoader.checkPackageAccess().
   136   //
   137   //
   137   ProtectionDomainEntry* _pd_set;
   138   ProtectionDomainEntry* volatile _pd_set;
   138 
   139 
   139  public:
   140  public:
   140   // Tells whether a protection is in the approved set.
   141   // Tells whether a protection is in the approved set.
   141   bool contains_protection_domain(oop protection_domain) const;
   142   bool contains_protection_domain(oop protection_domain) const;
   142   // Adds a protection domain to the approved set.
   143   // Adds a protection domain to the approved set.
   151 
   152 
   152   DictionaryEntry** next_addr() {
   153   DictionaryEntry** next_addr() {
   153     return (DictionaryEntry**)HashtableEntry<InstanceKlass*, mtClass>::next_addr();
   154     return (DictionaryEntry**)HashtableEntry<InstanceKlass*, mtClass>::next_addr();
   154   }
   155   }
   155 
   156 
   156   ProtectionDomainEntry* pd_set() const { return _pd_set; }
   157   ProtectionDomainEntry* pd_set() const            { return _pd_set; }
   157   void set_pd_set(ProtectionDomainEntry* pd_set) { _pd_set = pd_set; }
   158   void set_pd_set(ProtectionDomainEntry* new_head) {  _pd_set = new_head; }
       
   159 
       
   160   ProtectionDomainEntry* pd_set_acquire() const    {
       
   161     return (ProtectionDomainEntry*)OrderAccess::load_ptr_acquire(&_pd_set);
       
   162   }
       
   163   void release_set_pd_set(ProtectionDomainEntry* new_head) {
       
   164     OrderAccess::release_store_ptr(&_pd_set, new_head);
       
   165   }
   158 
   166 
   159   // Tells whether the initiating class' protection domain can access the klass in this entry
   167   // Tells whether the initiating class' protection domain can access the klass in this entry
   160   bool is_valid_protection_domain(Handle protection_domain) {
   168   bool is_valid_protection_domain(Handle protection_domain) {
   161     if (!ProtectionDomainVerification) return true;
   169     if (!ProtectionDomainVerification) return true;
   162     if (!SystemDictionary::has_checkPackageAccess()) return true;
   170     if (!SystemDictionary::has_checkPackageAccess()) return true;
   165          ? true
   173          ? true
   166          : contains_protection_domain(protection_domain());
   174          : contains_protection_domain(protection_domain());
   167   }
   175   }
   168 
   176 
   169   void verify_protection_domain_set() {
   177   void verify_protection_domain_set() {
   170     for (ProtectionDomainEntry* current = _pd_set;
   178     for (ProtectionDomainEntry* current = pd_set(); // accessed at a safepoint
   171                                 current != NULL;
   179                                 current != NULL;
   172                                 current = current->_next) {
   180                                 current = current->_next) {
   173       current->_pd_cache->protection_domain()->verify();
   181       current->_pd_cache->protection_domain()->verify();
   174     }
   182     }
   175   }
   183   }
   179     return (klass->name() == class_name);
   187     return (klass->name() == class_name);
   180   }
   188   }
   181 
   189 
   182   void print_count(outputStream *st) {
   190   void print_count(outputStream *st) {
   183     int count = 0;
   191     int count = 0;
   184     for (ProtectionDomainEntry* current = _pd_set;
   192     for (ProtectionDomainEntry* current = pd_set();  // accessed inside SD lock
   185                                 current != NULL;
   193                                 current != NULL;
   186                                 current = current->_next) {
   194                                 current = current->_next) {
   187       count++;
   195       count++;
   188     }
   196     }
   189     st->print_cr("pd set count = #%d", count);
   197     st->print_cr("pd set count = #%d", count);