< prev index next >

src/share/vm/classfile/dictionary.hpp

Print this page




  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_CLASSFILE_DICTIONARY_HPP
  26 #define SHARE_VM_CLASSFILE_DICTIONARY_HPP
  27 
  28 #include "classfile/protectionDomainCache.hpp"
  29 #include "classfile/systemDictionary.hpp"
  30 #include "oops/instanceKlass.hpp"
  31 #include "oops/oop.hpp"

  32 #include "utilities/hashtable.hpp"
  33 #include "utilities/ostream.hpp"
  34 
  35 class DictionaryEntry;
  36 class BoolObjectClosure;
  37 
  38 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  39 // The data structure for the class loader data dictionaries (and the shared system
  40 // dictionary).
  41 
  42 class Dictionary : public Hashtable<InstanceKlass*, mtClass> {
  43   friend class VMStructs;
  44 
  45   ClassLoaderData* _loader_data;  // backpointer to owning loader
  46   ClassLoaderData* loader_data() const { return _loader_data; }
  47 
  48   DictionaryEntry* get_entry(int index, unsigned int hash, Symbol* name);
  49 
  50 protected:
  51   DictionaryEntry* bucket(int i) const {


 117   // Contains the set of approved protection domains that can access
 118   // this dictionary entry.
 119   //
 120   // This protection domain set is a set of tuples:
 121   //
 122   // (InstanceKlass C, initiating class loader ICL, Protection Domain PD)
 123   //
 124   // [Note that C.protection_domain(), which is stored in the java.lang.Class
 125   // mirror of C, is NOT the same as PD]
 126   //
 127   // If such an entry (C, ICL, PD) exists in the table, it means that
 128   // it is okay for a class Foo to reference C, where
 129   //
 130   //    Foo.protection_domain() == PD, and
 131   //    Foo's defining class loader == ICL
 132   //
 133   // 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   // ClassLoader.checkPackageAccess().
 136   //
 137   ProtectionDomainEntry* _pd_set;
 138 
 139  public:
 140   // Tells whether a protection is in the approved set.
 141   bool contains_protection_domain(oop protection_domain) const;
 142   // Adds a protection domain to the approved set.
 143   void add_protection_domain(Dictionary* dict, Handle protection_domain);
 144 
 145   InstanceKlass* instance_klass() const { return literal(); }
 146   InstanceKlass** klass_addr() { return (InstanceKlass**)literal_addr(); }
 147 
 148   DictionaryEntry* next() const {
 149     return (DictionaryEntry*)HashtableEntry<InstanceKlass*, mtClass>::next();
 150   }
 151 
 152   DictionaryEntry** next_addr() {
 153     return (DictionaryEntry**)HashtableEntry<InstanceKlass*, mtClass>::next_addr();
 154   }
 155 
 156   ProtectionDomainEntry* pd_set() const { return _pd_set; }
 157   void set_pd_set(ProtectionDomainEntry* pd_set) { _pd_set = pd_set; }






 158 
 159   // Tells whether the initiating class' protection domain can access the klass in this entry
 160   bool is_valid_protection_domain(Handle protection_domain) {
 161     if (!ProtectionDomainVerification) return true;
 162     if (!SystemDictionary::has_checkPackageAccess()) return true;
 163 
 164     return protection_domain() == NULL
 165          ? true
 166          : contains_protection_domain(protection_domain());
 167   }
 168 
 169   void verify_protection_domain_set() {
 170     for (ProtectionDomainEntry* current = _pd_set;
 171                                 current != NULL;
 172                                 current = current->_next) {
 173       current->_pd_cache->protection_domain()->verify();
 174     }
 175   }
 176 
 177   bool equals(const Symbol* class_name) const {




  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_CLASSFILE_DICTIONARY_HPP
  26 #define SHARE_VM_CLASSFILE_DICTIONARY_HPP
  27 
  28 #include "classfile/protectionDomainCache.hpp"
  29 #include "classfile/systemDictionary.hpp"
  30 #include "oops/instanceKlass.hpp"
  31 #include "oops/oop.hpp"
  32 #include "runtime/orderAccess.hpp"
  33 #include "utilities/hashtable.hpp"
  34 #include "utilities/ostream.hpp"
  35 
  36 class DictionaryEntry;
  37 class BoolObjectClosure;
  38 
  39 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  40 // The data structure for the class loader data dictionaries (and the shared system
  41 // dictionary).
  42 
  43 class Dictionary : public Hashtable<InstanceKlass*, mtClass> {
  44   friend class VMStructs;
  45 
  46   ClassLoaderData* _loader_data;  // backpointer to owning loader
  47   ClassLoaderData* loader_data() const { return _loader_data; }
  48 
  49   DictionaryEntry* get_entry(int index, unsigned int hash, Symbol* name);
  50 
  51 protected:
  52   DictionaryEntry* bucket(int i) const {


 118   // Contains the set of approved protection domains that can access
 119   // this dictionary entry.
 120   //
 121   // This protection domain set is a set of tuples:
 122   //
 123   // (InstanceKlass C, initiating class loader ICL, Protection Domain PD)
 124   //
 125   // [Note that C.protection_domain(), which is stored in the java.lang.Class
 126   // mirror of C, is NOT the same as PD]
 127   //
 128   // If such an entry (C, ICL, PD) exists in the table, it means that
 129   // it is okay for a class Foo to reference C, where
 130   //
 131   //    Foo.protection_domain() == PD, and
 132   //    Foo's defining class loader == ICL
 133   //
 134   // The usage of the PD set can be seen in SystemDictionary::validate_protection_domain()
 135   // It is essentially a cache to avoid repeated Java up-calls to
 136   // ClassLoader.checkPackageAccess().
 137   //
 138   ProtectionDomainEntry* volatile _pd_set;
 139 
 140  public:
 141   // Tells whether a protection is in the approved set.
 142   bool contains_protection_domain(oop protection_domain) const;
 143   // Adds a protection domain to the approved set.
 144   void add_protection_domain(Dictionary* dict, Handle protection_domain);
 145 
 146   InstanceKlass* instance_klass() const { return literal(); }
 147   InstanceKlass** klass_addr() { return (InstanceKlass**)literal_addr(); }
 148 
 149   DictionaryEntry* next() const {
 150     return (DictionaryEntry*)HashtableEntry<InstanceKlass*, mtClass>::next();
 151   }
 152 
 153   DictionaryEntry** next_addr() {
 154     return (DictionaryEntry**)HashtableEntry<InstanceKlass*, mtClass>::next_addr();
 155   }
 156 
 157   ProtectionDomainEntry* pd_set() const { return (ProtectionDomainEntry*)OrderAccess::load_ptr_acquire(&_pd_set); }
 158   void set_pd_set(ProtectionDomainEntry* new_head) {
 159     // Warning: Preserve store ordering.  The SystemDictionary is read
 160     //          without locks.  The new ProtectionDomainEntry must be
 161     //          complete before other threads can be allowed to see it
 162     //          via a store to _pd_set.
 163     OrderAccess::release_store_ptr(&_pd_set, new_head);
 164   }
 165 
 166   // Tells whether the initiating class' protection domain can access the klass in this entry
 167   bool is_valid_protection_domain(Handle protection_domain) {
 168     if (!ProtectionDomainVerification) return true;
 169     if (!SystemDictionary::has_checkPackageAccess()) return true;
 170 
 171     return protection_domain() == NULL
 172          ? true
 173          : contains_protection_domain(protection_domain());
 174   }
 175 
 176   void verify_protection_domain_set() {
 177     for (ProtectionDomainEntry* current = _pd_set;
 178                                 current != NULL;
 179                                 current = current->_next) {
 180       current->_pd_cache->protection_domain()->verify();
 181     }
 182   }
 183 
 184   bool equals(const Symbol* class_name) const {


< prev index next >