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_MODULEENTRY_HPP
26 #define SHARE_VM_CLASSFILE_MODULEENTRY_HPP
27
28 #include "classfile/classLoaderData.hpp"
29 #include "classfile/vmSymbols.hpp"
30 #include "oops/symbol.hpp"
31 #include "prims/jni.h"
32 #include "runtime/mutexLocker.hpp"
33 #include "trace/traceMacros.hpp"
34 #include "utilities/growableArray.hpp"
35 #include "utilities/hashtable.hpp"
36 #include "utilities/ostream.hpp"
37
38 #define UNNAMED_MODULE "Unnamed Module"
39
40 class ModuleClosure;
41
42 // A ModuleEntry describes a module that has been defined by a call to JVM_DefineModule.
43 // It contains:
44 // - Symbol* containing the module's name.
45 // - pointer to the java.lang.reflect.Module for this module.
46 // - pointer to the java.security.ProtectionDomain shared by classes defined to this module.
47 // - ClassLoaderData*, class loader of this module.
48 // - a growable array containg other module entries that this module can read.
49 // - a flag indicating if this module can read all unnamed modules.
50 //
51 // The Mutex Module_lock is shared between ModuleEntry and PackageEntry, to lock either
52 // data structure.
65 TRACE_DEFINE_TRACE_ID_FIELD;
66 enum {MODULE_READS_SIZE = 101}; // Initial size of list of modules that the module can read.
67
68 public:
69 void init() {
70 _module = NULL;
71 _loader_data = NULL;
72 _pd = NULL;
73 _reads = NULL;
74 _version = NULL;
75 _location = NULL;
76 _can_read_all_unnamed = false;
77 _has_default_read_edges = false;
78 _must_walk_reads = false;
79 }
80
81 Symbol* name() const { return literal(); }
82 void set_name(Symbol* n) { set_literal(n); }
83
84 jobject module() const { return _module; }
85 void set_module(jobject j) { _module = j; }
86
87 // The shared ProtectionDomain reference is set once the VM loads a shared class
88 // originated from the current Module. The referenced ProtectionDomain object is
89 // created by the ClassLoader when loading a class (shared or non-shared) from the
90 // Module for the first time. This ProtectionDomain object is used for all
91 // classes from the Module loaded by the same ClassLoader.
92 Handle shared_protection_domain();
93 void set_shared_protection_domain(ClassLoaderData *loader_data, Handle pd);
94
95 ClassLoaderData* loader_data() const { return _loader_data; }
96 void set_loader_data(ClassLoaderData* l) { _loader_data = l; }
97
98 Symbol* version() const { return _version; }
99 void set_version(Symbol* version);
100
101 Symbol* location() const { return _location; }
102 void set_location(Symbol* location);
103
104 bool can_read(ModuleEntry* m) const;
105 bool has_reads() const;
203
204 // Create module in loader's module entry table, if already exists then
205 // return null. Assume Module_lock has been locked by caller.
206 ModuleEntry* locked_create_entry_or_null(Handle module_handle,
207 Symbol* module_name,
208 Symbol* module_version,
209 Symbol* module_location,
210 ClassLoaderData* loader_data);
211
212 // Only lookup module within loader's module entry table. The table read is lock-free.
213 ModuleEntry* lookup_only(Symbol* name);
214
215 // purge dead weak references out of reads list
216 void purge_all_module_reads();
217
218 // Special handling for unnamed module, one per class loader's ModuleEntryTable
219 void create_unnamed_module(ClassLoaderData* loader_data);
220 ModuleEntry* unnamed_module() { return _unnamed_module; }
221
222 // Special handling for java.base
223 static ModuleEntry* javabase_module() { return _javabase_module; }
224 static void set_javabase_module(ModuleEntry* java_base) { _javabase_module = java_base; }
225 static bool javabase_defined() { return ((_javabase_module != NULL) &&
226 (_javabase_module->module() != NULL)); }
227 static void finalize_javabase(Handle module_handle, Symbol* version, Symbol* location);
228 static void patch_javabase_entries(Handle module_handle);
229
230 void print(outputStream* st = tty);
231 void verify();
232 };
233
234 #endif // SHARE_VM_CLASSFILE_MODULEENTRY_HPP
|
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_MODULEENTRY_HPP
26 #define SHARE_VM_CLASSFILE_MODULEENTRY_HPP
27
28 #include "classfile/classLoaderData.hpp"
29 #include "classfile/vmSymbols.hpp"
30 #include "oops/symbol.hpp"
31 #include "prims/jni.h"
32 #include "runtime/mutexLocker.hpp"
33 #include "runtime/orderAccess.hpp"
34 #include "trace/traceMacros.hpp"
35 #include "utilities/growableArray.hpp"
36 #include "utilities/hashtable.hpp"
37 #include "utilities/ostream.hpp"
38
39 #define UNNAMED_MODULE "Unnamed Module"
40
41 class ModuleClosure;
42
43 // A ModuleEntry describes a module that has been defined by a call to JVM_DefineModule.
44 // It contains:
45 // - Symbol* containing the module's name.
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.
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 jobject module_load_acquire() const { return (jobject)OrderAccess::load_ptr_acquire(&_module); }
87 void set_module(jobject j) { _module = j; }
88 void set_module_release_store(jobject j) { OrderAccess::release_store_ptr(&_module, j); }
89
90
91 // The shared ProtectionDomain reference is set once the VM loads a shared class
92 // originated from the current Module. The referenced ProtectionDomain object is
93 // created by the ClassLoader when loading a class (shared or non-shared) from the
94 // Module for the first time. This ProtectionDomain object is used for all
95 // classes from the Module loaded by the same ClassLoader.
96 Handle shared_protection_domain();
97 void set_shared_protection_domain(ClassLoaderData *loader_data, Handle pd);
98
99 ClassLoaderData* loader_data() const { return _loader_data; }
100 void set_loader_data(ClassLoaderData* l) { _loader_data = l; }
101
102 Symbol* version() const { return _version; }
103 void set_version(Symbol* version);
104
105 Symbol* location() const { return _location; }
106 void set_location(Symbol* location);
107
108 bool can_read(ModuleEntry* m) const;
109 bool has_reads() const;
207
208 // Create module in loader's module entry table, if already exists then
209 // return null. Assume Module_lock has been locked by caller.
210 ModuleEntry* locked_create_entry_or_null(Handle module_handle,
211 Symbol* module_name,
212 Symbol* module_version,
213 Symbol* module_location,
214 ClassLoaderData* loader_data);
215
216 // Only lookup module within loader's module entry table. The table read is lock-free.
217 ModuleEntry* lookup_only(Symbol* name);
218
219 // purge dead weak references out of reads list
220 void purge_all_module_reads();
221
222 // Special handling for unnamed module, one per class loader's ModuleEntryTable
223 void create_unnamed_module(ClassLoaderData* loader_data);
224 ModuleEntry* unnamed_module() { return _unnamed_module; }
225
226 // Special handling for java.base
227 static ModuleEntry* javabase_moduleEntry() { return _javabase_module; }
228 static void set_javabase_moduleEntry(ModuleEntry* java_base) { _javabase_module = java_base; }
229 static bool javabase_defined() {
230 ModuleEntry* jb = javabase_moduleEntry();
231 return ((jb != NULL) && (jb->module_load_acquire() != NULL));
232 }
233 static void finalize_javabase(Handle module_handle, Symbol* version, Symbol* location);
234 static void patch_javabase_entries(Handle module_handle);
235
236 void print(outputStream* st = tty);
237 void verify();
238 };
239
240 #endif // SHARE_VM_CLASSFILE_MODULEENTRY_HPP
|