78 version->increment_refcount(); |
78 version->increment_refcount(); |
79 } |
79 } |
80 } |
80 } |
81 |
81 |
82 // Returns the shared ProtectionDomain |
82 // Returns the shared ProtectionDomain |
83 Handle ModuleEntry::shared_protection_domain() { |
83 oop ModuleEntry::shared_protection_domain() { |
84 return Handle(Thread::current(), JNIHandles::resolve(_pd)); |
84 return _pd.resolve(); |
85 } |
85 } |
86 |
86 |
87 // Set the shared ProtectionDomain atomically |
87 // Set the shared ProtectionDomain atomically |
88 void ModuleEntry::set_shared_protection_domain(ClassLoaderData *loader_data, |
88 void ModuleEntry::set_shared_protection_domain(ClassLoaderData *loader_data, |
89 Handle pd_h) { |
89 Handle pd_h) { |
90 // Create a handle for the shared ProtectionDomain and save it atomically. |
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. |
91 // init_handle_locked checks if someone beats us setting the _pd cache. |
92 jobject obj = loader_data->add_handle(pd_h); |
92 loader_data->init_handle_locked(_pd, pd_h); |
93 if (Atomic::cmpxchg_ptr(obj, &_pd, NULL) != NULL) { |
|
94 loader_data->remove_handle_unsafe(obj); |
|
95 } |
|
96 } |
93 } |
97 |
94 |
98 // Returns true if this module can read module m |
95 // Returns true if this module can read module m |
99 bool ModuleEntry::can_read(ModuleEntry* m) const { |
96 bool ModuleEntry::can_read(ModuleEntry* m) const { |
100 assert(m != NULL, "No module to lookup in this module's reads list"); |
97 assert(m != NULL, "No module to lookup in this module's reads list"); |