< 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 {
 178     InstanceKlass* klass = (InstanceKlass*)literal();
 179     return (klass->name() == class_name);
 180   }
 181 
 182   void print_count(outputStream *st) {
 183     int count = 0;
 184     for (ProtectionDomainEntry* current = _pd_set;
 185                                 current != NULL;
 186                                 current = current->_next) {
 187       count++;
 188     }
 189     st->print_cr("pd set count = #%d", count);
 190   }
 191 
 192   void verify();
 193 };
 194 
 195 // Entry in a SymbolPropertyTable, mapping a single Symbol*
 196 // to a managed and an unmanaged pointer.
 197 class SymbolPropertyEntry : public HashtableEntry<Symbol*, mtSymbol> {
 198   friend class VMStructs;
 199  private:
 200   intptr_t _symbol_mode;  // secondary key
 201   Method*   _method;
 202   oop       _method_type;
 203 
 204  public:




  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 _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   }
 166 
 167   // Tells whether the initiating class' protection domain can access the klass in this entry
 168   bool is_valid_protection_domain(Handle protection_domain) {
 169     if (!ProtectionDomainVerification) return true;
 170     if (!SystemDictionary::has_checkPackageAccess()) return true;
 171 
 172     return protection_domain() == NULL
 173          ? true
 174          : contains_protection_domain(protection_domain());
 175   }
 176 
 177   void verify_protection_domain_set() {
 178     for (ProtectionDomainEntry* current = pd_set();
 179                                 current != NULL;
 180                                 current = current->_next) {
 181       current->_pd_cache->protection_domain()->verify();
 182     }
 183   }
 184 
 185   bool equals(const Symbol* class_name) const {
 186     InstanceKlass* klass = (InstanceKlass*)literal();
 187     return (klass->name() == class_name);
 188   }
 189 
 190   void print_count(outputStream *st) {
 191     int count = 0;
 192     for (ProtectionDomainEntry* current = pd_set();
 193                                 current != NULL;
 194                                 current = current->_next) {
 195       count++;
 196     }
 197     st->print_cr("pd set count = #%d", count);
 198   }
 199 
 200   void verify();
 201 };
 202 
 203 // Entry in a SymbolPropertyTable, mapping a single Symbol*
 204 // to a managed and an unmanaged pointer.
 205 class SymbolPropertyEntry : public HashtableEntry<Symbol*, mtSymbol> {
 206   friend class VMStructs;
 207  private:
 208   intptr_t _symbol_mode;  // secondary key
 209   Method*   _method;
 210   oop       _method_type;
 211 
 212  public:


< prev index next >