1
|
1 |
/*
|
|
2 |
* Copyright 2003-2006 Sun Microsystems, Inc. All Rights Reserved.
|
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
|
7 |
* published by the Free Software Foundation.
|
|
8 |
*
|
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
|
20 |
* CA 95054 USA or visit www.sun.com if you need additional information or
|
|
21 |
* have any questions.
|
|
22 |
*
|
|
23 |
*/
|
|
24 |
|
|
25 |
class LoaderConstraintEntry;
|
|
26 |
|
|
27 |
class LoaderConstraintTable : public Hashtable {
|
|
28 |
friend class VMStructs;
|
|
29 |
private:
|
|
30 |
|
|
31 |
enum Constants {
|
|
32 |
_loader_constraint_size = 107, // number of entries in constraint table
|
|
33 |
_nof_buckets = 1009 // number of buckets in hash table
|
|
34 |
};
|
|
35 |
|
|
36 |
LoaderConstraintEntry** find_loader_constraint(symbolHandle name,
|
|
37 |
Handle loader);
|
|
38 |
|
|
39 |
public:
|
|
40 |
|
|
41 |
LoaderConstraintTable(int nof_buckets);
|
|
42 |
|
|
43 |
LoaderConstraintEntry* new_entry(unsigned int hash, symbolOop name,
|
|
44 |
klassOop klass, int num_loaders,
|
|
45 |
int max_loaders);
|
|
46 |
|
|
47 |
LoaderConstraintEntry* bucket(int i) {
|
|
48 |
return (LoaderConstraintEntry*)Hashtable::bucket(i);
|
|
49 |
}
|
|
50 |
|
|
51 |
LoaderConstraintEntry** bucket_addr(int i) {
|
|
52 |
return (LoaderConstraintEntry**)Hashtable::bucket_addr(i);
|
|
53 |
}
|
|
54 |
|
|
55 |
// GC support
|
|
56 |
void oops_do(OopClosure* f);
|
|
57 |
void always_strong_classes_do(OopClosure* blk);
|
|
58 |
|
|
59 |
// Check class loader constraints
|
|
60 |
bool add_entry(symbolHandle name, klassOop klass1, Handle loader1,
|
|
61 |
klassOop klass2, Handle loader2);
|
|
62 |
|
|
63 |
void check_signature_loaders(symbolHandle signature, Handle loader1,
|
|
64 |
Handle loader2, bool is_method, TRAPS);
|
|
65 |
|
|
66 |
klassOop find_constrained_klass(symbolHandle name, Handle loader);
|
|
67 |
klassOop find_constrained_elem_klass(symbolHandle name, symbolHandle elem_name,
|
|
68 |
Handle loader, TRAPS);
|
|
69 |
|
|
70 |
|
|
71 |
// Class loader constraints
|
|
72 |
|
|
73 |
void ensure_loader_constraint_capacity(LoaderConstraintEntry *p, int nfree);
|
|
74 |
void extend_loader_constraint(LoaderConstraintEntry* p, Handle loader,
|
|
75 |
klassOop klass);
|
|
76 |
void merge_loader_constraints(LoaderConstraintEntry** pp1,
|
|
77 |
LoaderConstraintEntry** pp2, klassOop klass);
|
|
78 |
|
|
79 |
bool check_or_update(instanceKlassHandle k, Handle loader,
|
|
80 |
symbolHandle name);
|
|
81 |
|
|
82 |
|
|
83 |
void purge_loader_constraints(BoolObjectClosure* is_alive);
|
|
84 |
|
|
85 |
void verify(Dictionary* dictionary);
|
|
86 |
#ifndef PRODUCT
|
|
87 |
void print();
|
|
88 |
#endif
|
|
89 |
};
|
|
90 |
|
|
91 |
class LoaderConstraintEntry : public HashtableEntry {
|
|
92 |
friend class VMStructs;
|
|
93 |
private:
|
|
94 |
symbolOop _name; // class name
|
|
95 |
int _num_loaders;
|
|
96 |
int _max_loaders;
|
|
97 |
oop* _loaders; // initiating loaders
|
|
98 |
|
|
99 |
public:
|
|
100 |
|
|
101 |
klassOop klass() { return (klassOop)literal(); }
|
|
102 |
klassOop* klass_addr() { return (klassOop*)literal_addr(); }
|
|
103 |
void set_klass(klassOop k) { set_literal(k); }
|
|
104 |
|
|
105 |
LoaderConstraintEntry* next() {
|
|
106 |
return (LoaderConstraintEntry*)HashtableEntry::next();
|
|
107 |
}
|
|
108 |
|
|
109 |
LoaderConstraintEntry** next_addr() {
|
|
110 |
return (LoaderConstraintEntry**)HashtableEntry::next_addr();
|
|
111 |
}
|
|
112 |
void set_next(LoaderConstraintEntry* next) {
|
|
113 |
HashtableEntry::set_next(next);
|
|
114 |
}
|
|
115 |
|
|
116 |
symbolOop name() { return _name; }
|
|
117 |
symbolOop* name_addr() { return &_name; }
|
|
118 |
void set_name(symbolOop name) { _name = name; }
|
|
119 |
|
|
120 |
int num_loaders() { return _num_loaders; }
|
|
121 |
void set_num_loaders(int i) { _num_loaders = i; }
|
|
122 |
|
|
123 |
int max_loaders() { return _max_loaders; }
|
|
124 |
void set_max_loaders(int i) { _max_loaders = i; }
|
|
125 |
|
|
126 |
oop* loaders() { return _loaders; }
|
|
127 |
void set_loaders(oop* loaders) { _loaders = loaders; }
|
|
128 |
|
|
129 |
oop loader(int i) { return _loaders[i]; }
|
|
130 |
oop* loader_addr(int i) { return &_loaders[i]; }
|
|
131 |
void set_loader(int i, oop p) { _loaders[i] = p; }
|
|
132 |
|
|
133 |
};
|