53 // - being not exported, to being exported either in a qualified or unqualified manner 54 // - being qualifiedly exported, to unqualifiedly exported. Its exported scope is widened. 55 // 56 // A package cannot transition from: 57 // - being unqualifiedly exported, to exported qualifiedly to a specific module. 58 // This transition attempt is silently ignored in set_exported. 59 // 60 // The Mutex Module_lock is shared between ModuleEntry and PackageEntry, to lock either 61 // data structure. 62 class PackageEntry : public HashtableEntry<Symbol*, mtModule> { 63 private: 64 ModuleEntry* _module; 65 // Used to indicate for packages with classes loaded by the boot loader that 66 // a class in that package has been loaded. And, for packages with classes 67 // loaded by the boot loader from -Xbootclasspath/a in an unnamed module, it 68 // indicates from which class path entry. 69 s2 _classpath_index; 70 bool _is_exported_unqualified; 71 bool _is_exported_allUnnamed; 72 bool _must_walk_exports; 73 GrowableArray<ModuleEntry*>* _exported_pending_delete; // transitioned from qualified to unqualified, delete at safepoint 74 GrowableArray<ModuleEntry*>* _qualified_exports; 75 TRACE_DEFINE_TRACE_ID_FIELD; 76 77 // Initial size of a package entry's list of qualified exports. 78 enum {QUAL_EXP_SIZE = 43}; 79 80 public: 81 void init() { 82 _module = NULL; 83 _classpath_index = -1; 84 _is_exported_unqualified = false; 85 _is_exported_allUnnamed = false; 86 _must_walk_exports = false; 87 _exported_pending_delete = NULL; 88 _qualified_exports = NULL; 89 } 90 91 // package name 92 Symbol* name() const { return literal(); } 93 void set_name(Symbol* n) { set_literal(n); } 94 95 // the module containing the package definition 96 ModuleEntry* module() const { return _module; } 97 void set_module(ModuleEntry* m) { _module = m; } 98 99 // package's export state 100 bool is_exported() const { // qualifiedly or unqualifiedly exported 101 return (is_unqual_exported() || has_qual_exports_list() || is_exported_allUnnamed()); 102 } 103 // Returns true if the package has any explicit qualified exports or is exported to all unnamed 104 bool is_qual_exported() const { 105 return (has_qual_exports_list() || is_exported_allUnnamed()); 106 } 107 // Returns true if there are any explicit qualified exports 108 bool has_qual_exports_list() const { 109 assert(!(_qualified_exports != NULL && _is_exported_unqualified), 110 "_qualified_exports set at same time as _is_exported_unqualified"); 111 return (_qualified_exports != NULL); 112 } 113 bool is_exported_allUnnamed() const { 114 assert(!(_is_exported_allUnnamed && _is_exported_unqualified), 115 "_is_exported_allUnnamed set at same time as _is_exported_unqualified"); 116 return _is_exported_allUnnamed; 117 } 118 bool is_unqual_exported() const { 119 assert(!(_qualified_exports != NULL && _is_exported_unqualified), 120 "_qualified_exports set at same time as _is_exported_unqualified"); 121 assert(!(_is_exported_allUnnamed && _is_exported_unqualified), 122 "_is_exported_allUnnamed set at same time as _is_exported_unqualified"); 123 return _is_exported_unqualified; 124 } 125 void set_unqual_exported() { 126 assert(Module_lock->owned_by_self(), "should have the Module_lock"); 127 _is_exported_unqualified = true; 128 _is_exported_allUnnamed = false; 129 _qualified_exports = NULL; 130 } 131 bool exported_pending_delete() const { return (_exported_pending_delete != NULL); } 132 133 void set_exported(ModuleEntry* m); 134 135 void set_is_exported_allUnnamed(); 136 137 void set_classpath_index(s2 classpath_index) { 138 _classpath_index = classpath_index; 139 } 140 s2 classpath_index() const { return _classpath_index; } 141 142 bool has_loaded_class() const { return _classpath_index != -1; } 143 144 // returns true if the package is defined in the unnamed module 145 bool in_unnamed_module() const { return !_module->is_named(); } 146 147 // returns true if the package specifies m as a qualified export, including through an unnamed export 148 bool is_qexported_to(ModuleEntry* m) const; 149 150 // add the module to the package's qualified exports 151 void add_qexport(ModuleEntry* m); | 53 // - being not exported, to being exported either in a qualified or unqualified manner 54 // - being qualifiedly exported, to unqualifiedly exported. Its exported scope is widened. 55 // 56 // A package cannot transition from: 57 // - being unqualifiedly exported, to exported qualifiedly to a specific module. 58 // This transition attempt is silently ignored in set_exported. 59 // 60 // The Mutex Module_lock is shared between ModuleEntry and PackageEntry, to lock either 61 // data structure. 62 class PackageEntry : public HashtableEntry<Symbol*, mtModule> { 63 private: 64 ModuleEntry* _module; 65 // Used to indicate for packages with classes loaded by the boot loader that 66 // a class in that package has been loaded. And, for packages with classes 67 // loaded by the boot loader from -Xbootclasspath/a in an unnamed module, it 68 // indicates from which class path entry. 69 s2 _classpath_index; 70 bool _is_exported_unqualified; 71 bool _is_exported_allUnnamed; 72 bool _must_walk_exports; 73 GrowableArray<ModuleEntry*>* _qualified_exports; 74 TRACE_DEFINE_TRACE_ID_FIELD; 75 76 // Initial size of a package entry's list of qualified exports. 77 enum {QUAL_EXP_SIZE = 43}; 78 79 public: 80 void init() { 81 _module = NULL; 82 _classpath_index = -1; 83 _is_exported_unqualified = false; 84 _is_exported_allUnnamed = false; 85 _must_walk_exports = false; 86 _qualified_exports = NULL; 87 } 88 89 // package name 90 Symbol* name() const { return literal(); } 91 void set_name(Symbol* n) { set_literal(n); } 92 93 // the module containing the package definition 94 ModuleEntry* module() const { return _module; } 95 void set_module(ModuleEntry* m) { _module = m; } 96 97 // package's export state 98 bool is_exported() const { // qualifiedly or unqualifiedly exported 99 return (is_unqual_exported() || has_qual_exports_list() || is_exported_allUnnamed()); 100 } 101 // Returns true if the package has any explicit qualified exports or is exported to all unnamed 102 bool is_qual_exported() const { 103 return (has_qual_exports_list() || is_exported_allUnnamed()); 104 } 105 // Returns true if there are any explicit qualified exports 106 bool has_qual_exports_list() const { 107 return (!is_unqual_exported() && _qualified_exports != NULL); 108 } 109 bool is_exported_allUnnamed() const { 110 return (!is_unqual_exported() && _is_exported_allUnnamed); 111 } 112 bool is_unqual_exported() const { 113 return _is_exported_unqualified; 114 } 115 void set_unqual_exported() { 116 assert(Module_lock->owned_by_self(), "should have the Module_lock"); 117 _is_exported_unqualified = true; 118 _is_exported_allUnnamed = false; 119 } 120 bool exported_pending_delete() const { return (is_unqual_exported() && _qualified_exports != NULL); } 121 122 void set_exported(ModuleEntry* m); 123 124 void set_is_exported_allUnnamed(); 125 126 void set_classpath_index(s2 classpath_index) { 127 _classpath_index = classpath_index; 128 } 129 s2 classpath_index() const { return _classpath_index; } 130 131 bool has_loaded_class() const { return _classpath_index != -1; } 132 133 // returns true if the package is defined in the unnamed module 134 bool in_unnamed_module() const { return !_module->is_named(); } 135 136 // returns true if the package specifies m as a qualified export, including through an unnamed export 137 bool is_qexported_to(ModuleEntry* m) const; 138 139 // add the module to the package's qualified exports 140 void add_qexport(ModuleEntry* m); |