60 // - a growable array containg other module entries that this module can read.
61 // - a flag indicating if this module can read all unnamed modules.
62 //
63 // The Mutex Module_lock is shared between ModuleEntry and PackageEntry, to lock either
64 // data structure.
65 class ModuleEntry : public HashtableEntry<Symbol*, mtModule> {
66 private:
67 OopHandle _module; // java.lang.Module
68 OopHandle _shared_pd; // java.security.ProtectionDomain, cached
69 // for shared classes from this module
70 ClassLoaderData* _loader_data;
71 GrowableArray<ModuleEntry*>* _reads; // list of modules that are readable by this module
72 Symbol* _version; // module version number
73 Symbol* _location; // module location
74 CDS_ONLY(int _shared_path_index;) // >=0 if classes in this module are in CDS archive
75 bool _can_read_all_unnamed;
76 bool _has_default_read_edges; // JVMTI redefine/retransform support
77 bool _must_walk_reads; // walk module's reads list at GC safepoints to purge out dead modules
78 bool _is_open; // whether the packages in the module are all unqualifiedly exported
79 bool _is_patched; // whether the module is patched via --patch-module
80 CDS_JAVA_HEAP_ONLY(narrowOop _archived_module_narrow_oop;)
81
82 JFR_ONLY(DEFINE_TRACE_ID_FIELD;)
83 enum {MODULE_READS_SIZE = 101}; // Initial size of list of modules that the module can read.
84
85 public:
86 void init() {
87 _module = OopHandle();
88 _shared_pd = OopHandle();
89 _loader_data = NULL;
90 _reads = NULL;
91 _version = NULL;
92 _location = NULL;
93 _can_read_all_unnamed = false;
94 _has_default_read_edges = false;
95 _must_walk_reads = false;
96 _is_patched = false;
97 _is_open = false;
98 CDS_ONLY(_shared_path_index = -1);
99 }
100
185 static ModuleEntry* create_boot_unnamed_module(ClassLoaderData* cld);
186 static ModuleEntry* new_unnamed_module_entry(Handle module_handle, ClassLoaderData* cld);
187 void delete_unnamed_module();
188
189 void print(outputStream* st = tty);
190 void verify();
191
192 CDS_ONLY(int shared_path_index() { return _shared_path_index;})
193
194 JFR_ONLY(DEFINE_TRACE_ID_METHODS;)
195
196 #if INCLUDE_CDS_JAVA_HEAP
197 void iterate_symbols(MetaspaceClosure* closure);
198 ModuleEntry* allocate_archived_entry() const;
199 void init_as_archived_entry();
200 void init_archived_oops();
201 static ModuleEntry* get_archived_entry(ModuleEntry* orig_entry);
202 static Array<ModuleEntry*>* write_growable_array(GrowableArray<ModuleEntry*>* array);
203 static GrowableArray<ModuleEntry*>* restore_growable_array(Array<ModuleEntry*>* archived_array);
204 void load_from_archive(ClassLoaderData* loader_data);
205 void restore_archive_oops(ClassLoaderData* loader_data);
206 #endif
207 };
208
209 // Iterator interface
210 class ModuleClosure: public StackObj {
211 public:
212 virtual void do_module(ModuleEntry* module) = 0;
213 };
214
215
216 // The ModuleEntryTable is a Hashtable containing a list of all modules defined
217 // by a particular class loader. Each module is represented as a ModuleEntry node.
218 //
219 // Each ModuleEntryTable contains a _javabase_module field which allows for the
220 // creation of java.base's ModuleEntry very early in bootstrapping before the
221 // corresponding JVM_DefineModule call for java.base occurs during module system
222 // initialization. Setting up java.base's ModuleEntry early enables classes,
223 // loaded prior to the module system being initialized to be created with their
224 // PackageEntry node's correctly pointing at java.base's ModuleEntry. No class
225 // outside of java.base is allowed to be loaded pre-module system initialization.
|
60 // - a growable array containg other module entries that this module can read.
61 // - a flag indicating if this module can read all unnamed modules.
62 //
63 // The Mutex Module_lock is shared between ModuleEntry and PackageEntry, to lock either
64 // data structure.
65 class ModuleEntry : public HashtableEntry<Symbol*, mtModule> {
66 private:
67 OopHandle _module; // java.lang.Module
68 OopHandle _shared_pd; // java.security.ProtectionDomain, cached
69 // for shared classes from this module
70 ClassLoaderData* _loader_data;
71 GrowableArray<ModuleEntry*>* _reads; // list of modules that are readable by this module
72 Symbol* _version; // module version number
73 Symbol* _location; // module location
74 CDS_ONLY(int _shared_path_index;) // >=0 if classes in this module are in CDS archive
75 bool _can_read_all_unnamed;
76 bool _has_default_read_edges; // JVMTI redefine/retransform support
77 bool _must_walk_reads; // walk module's reads list at GC safepoints to purge out dead modules
78 bool _is_open; // whether the packages in the module are all unqualifiedly exported
79 bool _is_patched; // whether the module is patched via --patch-module
80 CDS_JAVA_HEAP_ONLY(int _archived_module_index;)
81
82 JFR_ONLY(DEFINE_TRACE_ID_FIELD;)
83 enum {MODULE_READS_SIZE = 101}; // Initial size of list of modules that the module can read.
84
85 public:
86 void init() {
87 _module = OopHandle();
88 _shared_pd = OopHandle();
89 _loader_data = NULL;
90 _reads = NULL;
91 _version = NULL;
92 _location = NULL;
93 _can_read_all_unnamed = false;
94 _has_default_read_edges = false;
95 _must_walk_reads = false;
96 _is_patched = false;
97 _is_open = false;
98 CDS_ONLY(_shared_path_index = -1);
99 }
100
185 static ModuleEntry* create_boot_unnamed_module(ClassLoaderData* cld);
186 static ModuleEntry* new_unnamed_module_entry(Handle module_handle, ClassLoaderData* cld);
187 void delete_unnamed_module();
188
189 void print(outputStream* st = tty);
190 void verify();
191
192 CDS_ONLY(int shared_path_index() { return _shared_path_index;})
193
194 JFR_ONLY(DEFINE_TRACE_ID_METHODS;)
195
196 #if INCLUDE_CDS_JAVA_HEAP
197 void iterate_symbols(MetaspaceClosure* closure);
198 ModuleEntry* allocate_archived_entry() const;
199 void init_as_archived_entry();
200 void init_archived_oops();
201 static ModuleEntry* get_archived_entry(ModuleEntry* orig_entry);
202 static Array<ModuleEntry*>* write_growable_array(GrowableArray<ModuleEntry*>* array);
203 static GrowableArray<ModuleEntry*>* restore_growable_array(Array<ModuleEntry*>* archived_array);
204 void load_from_archive(ClassLoaderData* loader_data);
205 void restore_archived_oops(ClassLoaderData* loader_data);
206 void clear_archived_oops();
207 #endif
208 };
209
210 // Iterator interface
211 class ModuleClosure: public StackObj {
212 public:
213 virtual void do_module(ModuleEntry* module) = 0;
214 };
215
216
217 // The ModuleEntryTable is a Hashtable containing a list of all modules defined
218 // by a particular class loader. Each module is represented as a ModuleEntry node.
219 //
220 // Each ModuleEntryTable contains a _javabase_module field which allows for the
221 // creation of java.base's ModuleEntry very early in bootstrapping before the
222 // corresponding JVM_DefineModule call for java.base occurs during module system
223 // initialization. Setting up java.base's ModuleEntry early enables classes,
224 // loaded prior to the module system being initialized to be created with their
225 // PackageEntry node's correctly pointing at java.base's ModuleEntry. No class
226 // outside of java.base is allowed to be loaded pre-module system initialization.
|