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 static bool _some_dictionary_needs_resizing;
47 bool _resizable;
48 bool _needs_resizing;
49 void check_if_needs_resize();
50
51 ClassLoaderData* _loader_data; // backpointer to owning loader
52 ClassLoaderData* loader_data() const { return _loader_data; }
153 public:
154 // Tells whether a protection is in the approved set.
155 bool contains_protection_domain(oop protection_domain) const;
156 // Adds a protection domain to the approved set.
157 void add_protection_domain(Dictionary* dict, Handle protection_domain);
158
159 InstanceKlass* instance_klass() const { return literal(); }
160 InstanceKlass** klass_addr() { return (InstanceKlass**)literal_addr(); }
161
162 DictionaryEntry* next() const {
163 return (DictionaryEntry*)HashtableEntry<InstanceKlass*, mtClass>::next();
164 }
165
166 DictionaryEntry** next_addr() {
167 return (DictionaryEntry**)HashtableEntry<InstanceKlass*, mtClass>::next_addr();
168 }
169
170 ProtectionDomainEntry* pd_set() const { return _pd_set; }
171 void set_pd_set(ProtectionDomainEntry* new_head) { _pd_set = new_head; }
172
173 ProtectionDomainEntry* pd_set_acquire() const {
174 return OrderAccess::load_acquire(&_pd_set);
175 }
176 void release_set_pd_set(ProtectionDomainEntry* new_head) {
177 OrderAccess::release_store(&_pd_set, new_head);
178 }
179
180 // Tells whether the initiating class' protection domain can access the klass in this entry
181 bool is_valid_protection_domain(Handle protection_domain) {
182 if (!ProtectionDomainVerification) return true;
183 if (!SystemDictionary::has_checkPackageAccess()) return true;
184
185 return protection_domain() == NULL
186 ? true
187 : contains_protection_domain(protection_domain());
188 }
189
190 void verify_protection_domain_set() {
191 for (ProtectionDomainEntry* current = pd_set(); // accessed at a safepoint
192 current != NULL;
193 current = current->_next) {
194 current->_pd_cache->object_no_keepalive()->verify();
195 }
196 }
197
198 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 "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 static bool _some_dictionary_needs_resizing;
46 bool _resizable;
47 bool _needs_resizing;
48 void check_if_needs_resize();
49
50 ClassLoaderData* _loader_data; // backpointer to owning loader
51 ClassLoaderData* loader_data() const { return _loader_data; }
152 public:
153 // Tells whether a protection is in the approved set.
154 bool contains_protection_domain(oop protection_domain) const;
155 // Adds a protection domain to the approved set.
156 void add_protection_domain(Dictionary* dict, Handle protection_domain);
157
158 InstanceKlass* instance_klass() const { return literal(); }
159 InstanceKlass** klass_addr() { return (InstanceKlass**)literal_addr(); }
160
161 DictionaryEntry* next() const {
162 return (DictionaryEntry*)HashtableEntry<InstanceKlass*, mtClass>::next();
163 }
164
165 DictionaryEntry** next_addr() {
166 return (DictionaryEntry**)HashtableEntry<InstanceKlass*, mtClass>::next_addr();
167 }
168
169 ProtectionDomainEntry* pd_set() const { return _pd_set; }
170 void set_pd_set(ProtectionDomainEntry* new_head) { _pd_set = new_head; }
171
172 ProtectionDomainEntry* pd_set_acquire() const;
173 void release_set_pd_set(ProtectionDomainEntry* new_head);
174
175 // Tells whether the initiating class' protection domain can access the klass in this entry
176 bool is_valid_protection_domain(Handle protection_domain) {
177 if (!ProtectionDomainVerification) return true;
178 if (!SystemDictionary::has_checkPackageAccess()) return true;
179
180 return protection_domain() == NULL
181 ? true
182 : contains_protection_domain(protection_domain());
183 }
184
185 void verify_protection_domain_set() {
186 for (ProtectionDomainEntry* current = pd_set(); // accessed at a safepoint
187 current != NULL;
188 current = current->_next) {
189 current->_pd_cache->object_no_keepalive()->verify();
190 }
191 }
192
193 bool equals(const Symbol* class_name) const {
|