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_CLASSFILE_PACKAGEENTRY_HPP
26 #define SHARE_CLASSFILE_PACKAGEENTRY_HPP
27
28 #include "classfile/moduleEntry.hpp"
29 #include "oops/symbol.hpp"
30 #include "runtime/atomic.hpp"
31 #include "utilities/growableArray.hpp"
32 #include "utilities/hashtable.hpp"
33 #include "utilities/macros.hpp"
34 #include "utilities/ostream.hpp"
35 #if INCLUDE_JFR
36 #include "jfr/support/jfrTraceIdExtension.hpp"
37 #endif
38
39
40 // A PackageEntry basically represents a Java package. It contains:
41 // - Symbol* containing the package's name.
42 // - ModuleEntry* for this package's containing module.
43 // - a field indicating if the package is exported unqualifiedly or to all
44 // unnamed modules.
45 // - a growable array containing other module entries that this
46 // package is exported to.
47 //
48 // Packages can be exported in the following 3 ways:
49 // - not exported: the package does not have qualified or unqualified exports.
50 // - qualified exports: the package has been explicitly qualified to at least
51 // one particular module or has been qualifiedly exported
52 // to all unnamed modules.
53 // Note: being exported to all unnamed is a form of a qualified
54 // export. It is equivalent to the package being explicitly
55 // exported to all current and future unnamed modules.
56 // - unqualified exports: the package is exported to all modules.
57 //
58 // A package can transition from:
200 PackageEntry* next() const {
201 return (PackageEntry*)HashtableEntry<Symbol*, mtModule>::next();
202 }
203
204 PackageEntry** next_addr() {
205 return (PackageEntry**)HashtableEntry<Symbol*, mtModule>::next_addr();
206 }
207
208 // iteration of qualified exports
209 void package_exports_do(ModuleClosure* f);
210
211 JFR_ONLY(DEFINE_TRACE_ID_METHODS;)
212
213 // Purge dead weak references out of exported list when any given class loader is unloaded.
214 void purge_qualified_exports();
215 void delete_qualified_exports();
216
217 void print(outputStream* st = tty);
218 void verify();
219
220 static int max_index_for_defined_in_class_path() {
221 return sizeof(int) * BitsPerByte;
222 }
223
224 bool is_defined_by_cds_in_class_path(int idx) const {
225 assert(idx < max_index_for_defined_in_class_path(), "sanity");
226 return((Atomic::load(&_defined_by_cds_in_class_path) & ((int)1 << idx)) != 0);
227 }
228 void set_defined_by_cds_in_class_path(int idx) {
229 assert(idx < max_index_for_defined_in_class_path(), "sanity");
230 int old_val = 0;
231 int new_val = 0;
232 do {
233 old_val = Atomic::load(&_defined_by_cds_in_class_path);
234 new_val = old_val | ((int)1 << idx);
235 } while (Atomic::cmpxchg(&_defined_by_cds_in_class_path, old_val, new_val) != old_val);
236 }
237 };
238
239 // The PackageEntryTable is a Hashtable containing a list of all packages defined
278
279 // Lookup Package with loader's package entry table, add it if not found.
280 // This will acquire the Module lock.
281 PackageEntry* lookup(Symbol* name, ModuleEntry* module);
282
283 // Only lookup Package within loader's package entry table.
284 // This will acquire the Module lock.
285 PackageEntry* lookup_only(Symbol* Package);
286
287 // Only lookup Package within loader's package entry table. Assume Module lock
288 // was taken by caller.
289 PackageEntry* locked_lookup_only(Symbol* Package);
290
291 void verify_javabase_packages(GrowableArray<Symbol*> *pkg_list);
292
293 // purge dead weak references out of exported list
294 void purge_all_package_exports();
295
296 void print(outputStream* st = tty);
297 void verify();
298 };
299
300 #endif // SHARE_CLASSFILE_PACKAGEENTRY_HPP
|
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_CLASSFILE_PACKAGEENTRY_HPP
26 #define SHARE_CLASSFILE_PACKAGEENTRY_HPP
27
28 #include "classfile/moduleEntry.hpp"
29 #include "oops/symbol.hpp"
30 #include "runtime/atomic.hpp"
31 #include "utilities/growableArray.hpp"
32 #include "utilities/hashtable.hpp"
33 #include "utilities/macros.hpp"
34 #include "utilities/ostream.hpp"
35 #if INCLUDE_JFR
36 #include "jfr/support/jfrTraceIdExtension.hpp"
37 #endif
38
39 template <class T> class Array;
40
41 // A PackageEntry basically represents a Java package. It contains:
42 // - Symbol* containing the package's name.
43 // - ModuleEntry* for this package's containing module.
44 // - a field indicating if the package is exported unqualifiedly or to all
45 // unnamed modules.
46 // - a growable array containing other module entries that this
47 // package is exported to.
48 //
49 // Packages can be exported in the following 3 ways:
50 // - not exported: the package does not have qualified or unqualified exports.
51 // - qualified exports: the package has been explicitly qualified to at least
52 // one particular module or has been qualifiedly exported
53 // to all unnamed modules.
54 // Note: being exported to all unnamed is a form of a qualified
55 // export. It is equivalent to the package being explicitly
56 // exported to all current and future unnamed modules.
57 // - unqualified exports: the package is exported to all modules.
58 //
59 // A package can transition from:
201 PackageEntry* next() const {
202 return (PackageEntry*)HashtableEntry<Symbol*, mtModule>::next();
203 }
204
205 PackageEntry** next_addr() {
206 return (PackageEntry**)HashtableEntry<Symbol*, mtModule>::next_addr();
207 }
208
209 // iteration of qualified exports
210 void package_exports_do(ModuleClosure* f);
211
212 JFR_ONLY(DEFINE_TRACE_ID_METHODS;)
213
214 // Purge dead weak references out of exported list when any given class loader is unloaded.
215 void purge_qualified_exports();
216 void delete_qualified_exports();
217
218 void print(outputStream* st = tty);
219 void verify();
220
221 #if INCLUDE_CDS_JAVA_HEAP
222 PackageEntry* allocate_archived_entry() const;
223 void init_as_archived_entry();
224 static PackageEntry* get_archived_entry(PackageEntry* orig_entry);
225 void load_from_archive();
226 #endif
227
228 static int max_index_for_defined_in_class_path() {
229 return sizeof(int) * BitsPerByte;
230 }
231
232 bool is_defined_by_cds_in_class_path(int idx) const {
233 assert(idx < max_index_for_defined_in_class_path(), "sanity");
234 return((Atomic::load(&_defined_by_cds_in_class_path) & ((int)1 << idx)) != 0);
235 }
236 void set_defined_by_cds_in_class_path(int idx) {
237 assert(idx < max_index_for_defined_in_class_path(), "sanity");
238 int old_val = 0;
239 int new_val = 0;
240 do {
241 old_val = Atomic::load(&_defined_by_cds_in_class_path);
242 new_val = old_val | ((int)1 << idx);
243 } while (Atomic::cmpxchg(&_defined_by_cds_in_class_path, old_val, new_val) != old_val);
244 }
245 };
246
247 // The PackageEntryTable is a Hashtable containing a list of all packages defined
286
287 // Lookup Package with loader's package entry table, add it if not found.
288 // This will acquire the Module lock.
289 PackageEntry* lookup(Symbol* name, ModuleEntry* module);
290
291 // Only lookup Package within loader's package entry table.
292 // This will acquire the Module lock.
293 PackageEntry* lookup_only(Symbol* Package);
294
295 // Only lookup Package within loader's package entry table. Assume Module lock
296 // was taken by caller.
297 PackageEntry* locked_lookup_only(Symbol* Package);
298
299 void verify_javabase_packages(GrowableArray<Symbol*> *pkg_list);
300
301 // purge dead weak references out of exported list
302 void purge_all_package_exports();
303
304 void print(outputStream* st = tty);
305 void verify();
306
307 #if INCLUDE_CDS_JAVA_HEAP
308 Array<PackageEntry*>* allocate_archived_entries();
309 void init_archived_entries(Array<PackageEntry*>* archived_packages);
310 void load_archived_entries(Array<PackageEntry*>* archived_packages);
311 #endif
312 };
313
314 #endif // SHARE_CLASSFILE_PACKAGEENTRY_HPP
|