46 // - pointer to the java.lang.reflect.Module for this module. 47 // - pointer to the java.security.ProtectionDomain shared by classes defined to this module. 48 // - ClassLoaderData*, class loader of this module. 49 // - a growable array containg other module entries that this module can read. 50 // - a flag indicating if this module can read all unnamed modules. 51 // 52 // The Mutex Module_lock is shared between ModuleEntry and PackageEntry, to lock either 53 // data structure. 54 class ModuleEntry : public HashtableEntry<Symbol*, mtModule> { 55 private: 56 jobject _module; // java.lang.reflect.Module 57 jobject _pd; // java.security.ProtectionDomain, cached 58 // for shared classes from this module 59 ClassLoaderData* _loader_data; 60 GrowableArray<ModuleEntry*>* _reads; // list of modules that are readable by this module 61 Symbol* _version; // module version number 62 Symbol* _location; // module location 63 bool _can_read_all_unnamed; 64 bool _has_default_read_edges; // JVMTI redefine/retransform support 65 bool _must_walk_reads; // walk module's reads list at GC safepoints to purge out dead modules 66 TRACE_DEFINE_TRACE_ID_FIELD; 67 enum {MODULE_READS_SIZE = 101}; // Initial size of list of modules that the module can read. 68 69 public: 70 void init() { 71 _module = NULL; 72 _loader_data = NULL; 73 _pd = NULL; 74 _reads = NULL; 75 _version = NULL; 76 _location = NULL; 77 _can_read_all_unnamed = false; 78 _has_default_read_edges = false; 79 _must_walk_reads = false; 80 } 81 82 Symbol* name() const { return literal(); } 83 void set_name(Symbol* n) { set_literal(n); } 84 85 jobject module() const { return _module; } 86 void set_module(jobject j) { _module = j; } 87 88 // The shared ProtectionDomain reference is set once the VM loads a shared class 89 // originated from the current Module. The referenced ProtectionDomain object is 90 // created by the ClassLoader when loading a class (shared or non-shared) from the 91 // Module for the first time. This ProtectionDomain object is used for all 92 // classes from the Module loaded by the same ClassLoader. 93 Handle shared_protection_domain(); 94 void set_shared_protection_domain(ClassLoaderData *loader_data, Handle pd); 95 96 ClassLoaderData* loader_data() const { return _loader_data; } 97 void set_loader_data(ClassLoaderData* l) { _loader_data = l; } 98 99 Symbol* version() const { return _version; } 112 113 bool can_read_all_unnamed() const { 114 assert(is_named() || _can_read_all_unnamed == true, 115 "unnamed modules can always read all unnamed modules"); 116 return _can_read_all_unnamed; 117 } 118 119 // Modules can only go from strict to loose. 120 void set_can_read_all_unnamed() { _can_read_all_unnamed = true; } 121 122 bool has_default_read_edges() const { 123 return _has_default_read_edges; 124 } 125 126 // Sets true and returns the previous value. 127 bool set_has_default_read_edges() { 128 MutexLocker ml(Module_lock); 129 bool prev = _has_default_read_edges; 130 _has_default_read_edges = true; 131 return prev; 132 } 133 134 ModuleEntry* next() const { 135 return (ModuleEntry*)HashtableEntry<Symbol*, mtModule>::next(); 136 } 137 ModuleEntry** next_addr() { 138 return (ModuleEntry**)HashtableEntry<Symbol*, mtModule>::next_addr(); 139 } 140 141 // iteration support for readability 142 void module_reads_do(ModuleClosure* const f); 143 144 TRACE_DEFINE_TRACE_ID_METHODS; 145 146 // Purge dead weak references out of reads list when any given class loader is unloaded. 147 void purge_reads(); 148 void delete_reads(); 149 150 void print(outputStream* st = tty); 151 void verify(); | 46 // - pointer to the java.lang.reflect.Module for this module. 47 // - pointer to the java.security.ProtectionDomain shared by classes defined to this module. 48 // - ClassLoaderData*, class loader of this module. 49 // - a growable array containg other module entries that this module can read. 50 // - a flag indicating if this module can read all unnamed modules. 51 // 52 // The Mutex Module_lock is shared between ModuleEntry and PackageEntry, to lock either 53 // data structure. 54 class ModuleEntry : public HashtableEntry<Symbol*, mtModule> { 55 private: 56 jobject _module; // java.lang.reflect.Module 57 jobject _pd; // java.security.ProtectionDomain, cached 58 // for shared classes from this module 59 ClassLoaderData* _loader_data; 60 GrowableArray<ModuleEntry*>* _reads; // list of modules that are readable by this module 61 Symbol* _version; // module version number 62 Symbol* _location; // module location 63 bool _can_read_all_unnamed; 64 bool _has_default_read_edges; // JVMTI redefine/retransform support 65 bool _must_walk_reads; // walk module's reads list at GC safepoints to purge out dead modules 66 bool _is_patched; // whether the module is patched via --patch-module 67 TRACE_DEFINE_TRACE_ID_FIELD; 68 enum {MODULE_READS_SIZE = 101}; // Initial size of list of modules that the module can read. 69 70 public: 71 void init() { 72 _module = NULL; 73 _loader_data = NULL; 74 _pd = NULL; 75 _reads = NULL; 76 _version = NULL; 77 _location = NULL; 78 _can_read_all_unnamed = false; 79 _has_default_read_edges = false; 80 _must_walk_reads = false; 81 _is_patched = false; 82 } 83 84 Symbol* name() const { return literal(); } 85 void set_name(Symbol* n) { set_literal(n); } 86 87 jobject module() const { return _module; } 88 void set_module(jobject j) { _module = j; } 89 90 // The shared ProtectionDomain reference is set once the VM loads a shared class 91 // originated from the current Module. The referenced ProtectionDomain object is 92 // created by the ClassLoader when loading a class (shared or non-shared) from the 93 // Module for the first time. This ProtectionDomain object is used for all 94 // classes from the Module loaded by the same ClassLoader. 95 Handle shared_protection_domain(); 96 void set_shared_protection_domain(ClassLoaderData *loader_data, Handle pd); 97 98 ClassLoaderData* loader_data() const { return _loader_data; } 99 void set_loader_data(ClassLoaderData* l) { _loader_data = l; } 100 101 Symbol* version() const { return _version; } 114 115 bool can_read_all_unnamed() const { 116 assert(is_named() || _can_read_all_unnamed == true, 117 "unnamed modules can always read all unnamed modules"); 118 return _can_read_all_unnamed; 119 } 120 121 // Modules can only go from strict to loose. 122 void set_can_read_all_unnamed() { _can_read_all_unnamed = true; } 123 124 bool has_default_read_edges() const { 125 return _has_default_read_edges; 126 } 127 128 // Sets true and returns the previous value. 129 bool set_has_default_read_edges() { 130 MutexLocker ml(Module_lock); 131 bool prev = _has_default_read_edges; 132 _has_default_read_edges = true; 133 return prev; 134 } 135 136 void set_is_patched() { 137 _is_patched = true; 138 } 139 bool is_patched() { 140 return _is_patched; 141 } 142 143 ModuleEntry* next() const { 144 return (ModuleEntry*)HashtableEntry<Symbol*, mtModule>::next(); 145 } 146 ModuleEntry** next_addr() { 147 return (ModuleEntry**)HashtableEntry<Symbol*, mtModule>::next_addr(); 148 } 149 150 // iteration support for readability 151 void module_reads_do(ModuleClosure* const f); 152 153 TRACE_DEFINE_TRACE_ID_METHODS; 154 155 // Purge dead weak references out of reads list when any given class loader is unloaded. 156 void purge_reads(); 157 void delete_reads(); 158 159 void print(outputStream* st = tty); 160 void verify(); |