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.
53 class ModuleEntry : public HashtableEntry<Symbol*, mtModule> {
54 private:
55 jobject _module; // java.lang.reflect.Module
56 jobject _pd; // java.security.ProtectionDomain, cached
57 // for shared classes from this module
58 ClassLoaderData* _loader_data;
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;
106 void add_read(ModuleEntry* m);
107 void set_read_walk_required(ClassLoaderData* m_loader_data);
108
109 bool is_named() const { return (name() != NULL); }
110
111 bool can_read_all_unnamed() const {
112 assert(is_named() || _can_read_all_unnamed == true,
113 "unnamed modules can always read all unnamed modules");
114 return _can_read_all_unnamed;
115 }
116
117 // Modules can only go from strict to loose.
118 void set_can_read_all_unnamed() { _can_read_all_unnamed = true; }
119
120 bool has_default_read_edges() const {
121 return _has_default_read_edges;
122 }
|
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 #define JAVA_BASE_NAME "java.base"
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.
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;
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; }
100 void set_version(Symbol* version);
101
102 Symbol* location() const { return _location; }
103 void set_location(Symbol* location);
104 bool is_non_jdk_module();
105
106 bool can_read(ModuleEntry* m) const;
107 bool has_reads() const;
108 void add_read(ModuleEntry* m);
109 void set_read_walk_required(ClassLoaderData* m_loader_data);
110
111 bool is_named() const { return (name() != NULL); }
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 }
|