63 } 64 } 65 return false; 66 } 67 68 void ModuleEntry::set_version(Symbol* version) { 69 if (_version != NULL) { 70 // _version symbol's refcounts are managed by ModuleEntry, 71 // must decrement the old one before updating. 72 _version->decrement_refcount(); 73 } 74 75 _version = version; 76 77 if (version != NULL) { 78 version->increment_refcount(); 79 } 80 } 81 82 // Returns the shared ProtectionDomain 83 Handle ModuleEntry::shared_protection_domain() { 84 return Handle(Thread::current(), JNIHandles::resolve(_pd)); 85 } 86 87 // Set the shared ProtectionDomain atomically 88 void ModuleEntry::set_shared_protection_domain(ClassLoaderData *loader_data, 89 Handle pd_h) { 90 // Create a handle for the shared ProtectionDomain and save it atomically. 91 // If someone beats us setting the _pd cache, the created handle is destroyed. 92 jobject obj = loader_data->add_handle(pd_h); 93 if (Atomic::cmpxchg_ptr(obj, &_pd, NULL) != NULL) { 94 loader_data->remove_handle_unsafe(obj); 95 } 96 } 97 98 // Returns true if this module can read module m 99 bool ModuleEntry::can_read(ModuleEntry* m) const { 100 assert(m != NULL, "No module to lookup in this module's reads list"); 101 102 // Unnamed modules read everyone and all modules 103 // read java.base. If either of these conditions 104 // hold, readability has been established. 105 if (!this->is_named() || 106 (m == ModuleEntryTable::javabase_moduleEntry())) { 107 return true; 108 } 109 110 MutexLocker m1(Module_lock); 111 // This is a guard against possible race between agent threads that redefine 112 // or retransform classes in this module. Only one of them is adding the 113 // default read edges to the unnamed modules of the boot and app class loaders | 63 } 64 } 65 return false; 66 } 67 68 void ModuleEntry::set_version(Symbol* version) { 69 if (_version != NULL) { 70 // _version symbol's refcounts are managed by ModuleEntry, 71 // must decrement the old one before updating. 72 _version->decrement_refcount(); 73 } 74 75 _version = version; 76 77 if (version != NULL) { 78 version->increment_refcount(); 79 } 80 } 81 82 // Returns the shared ProtectionDomain 83 oop ModuleEntry::shared_protection_domain() { 84 return _pd.resolve_acquire(); 85 } 86 87 // Set the shared ProtectionDomain atomically 88 void ModuleEntry::set_shared_protection_domain(ClassLoaderData *loader_data, 89 Handle pd_h) { 90 // Create a handle for the shared ProtectionDomain and save it atomically. 91 // If someone beats us setting the _pd cache, the created handle is destroyed. 92 OopHandle obj = loader_data->add_handle(pd_h); 93 if (!_pd.set_atomic(obj)) { 94 loader_data->remove_handle_unsafe(obj); 95 } 96 } 97 98 // Returns true if this module can read module m 99 bool ModuleEntry::can_read(ModuleEntry* m) const { 100 assert(m != NULL, "No module to lookup in this module's reads list"); 101 102 // Unnamed modules read everyone and all modules 103 // read java.base. If either of these conditions 104 // hold, readability has been established. 105 if (!this->is_named() || 106 (m == ModuleEntryTable::javabase_moduleEntry())) { 107 return true; 108 } 109 110 MutexLocker m1(Module_lock); 111 // This is a guard against possible race between agent threads that redefine 112 // or retransform classes in this module. Only one of them is adding the 113 // default read edges to the unnamed modules of the boot and app class loaders |