< prev index next >

src/hotspot/share/cds/cdsProtectionDomain.cpp

Print this page

 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *
 23  */
 24 
 25 #include "cds/aotClassLocation.hpp"
 26 #include "cds/cdsConfig.hpp"
 27 #include "cds/cdsProtectionDomain.hpp"
 28 #include "classfile/classLoader.hpp"
 29 #include "classfile/classLoaderData.inline.hpp"
 30 #include "classfile/classLoaderExt.hpp"
 31 #include "classfile/javaClasses.hpp"
 32 #include "classfile/moduleEntry.hpp"
 33 #include "classfile/systemDictionaryShared.hpp"
 34 #include "classfile/vmClasses.hpp"
 35 #include "classfile/vmSymbols.hpp"
 36 #include "memory/oopFactory.hpp"
 37 #include "memory/resourceArea.hpp"
 38 #include "memory/universe.hpp"
 39 #include "oops/instanceKlass.hpp"

 40 #include "oops/symbol.hpp"
 41 #include "runtime/javaCalls.hpp"
 42 
 43 OopHandle CDSProtectionDomain::_shared_protection_domains;
 44 OopHandle CDSProtectionDomain::_shared_jar_urls;
 45 OopHandle CDSProtectionDomain::_shared_jar_manifests;
 46 
 47 // Initializes the java.lang.Package and java.security.ProtectionDomain objects associated with
 48 // the given InstanceKlass.
 49 // Returns the ProtectionDomain for the InstanceKlass.
 50 Handle CDSProtectionDomain::init_security_info(Handle class_loader, InstanceKlass* ik, PackageEntry* pkg_entry, TRAPS) {
 51   int index = ik->shared_classpath_index();
 52   assert(index >= 0, "Sanity");
 53   const AOTClassLocation* cl = AOTClassLocationConfig::runtime()->class_location_at(index);
 54   Symbol* class_name = ik->name();
 55 
 56   if (cl->is_modules_image()) {
 57     // For shared app/platform classes originated from the run-time image:
 58     //   The ProtectionDomains are cached in the corresponding ModuleEntries
 59     //   for fast access by the VM.

279                                location_string, CHECK_NH);
280         url = Handle(THREAD, result.get_oop());
281       }
282 
283       Handle pd = get_protection_domain_from_classloader(class_loader, url,
284                                                          CHECK_NH);
285       mod->set_shared_protection_domain(loader_data, pd);
286     }
287   }
288 
289   Handle protection_domain(THREAD, mod->shared_protection_domain());
290   assert(protection_domain.not_null(), "sanity");
291   return protection_domain;
292 }
293 
294 void CDSProtectionDomain::atomic_set_array_index(OopHandle array, int index, oop o) {
295   // Benign race condition:  array.obj_at(index) may already be filled in.
296   // The important thing here is that all threads pick up the same result.
297   // It doesn't matter which racing thread wins, as long as only one
298   // result is used by all threads, and all future queries.
299   ((objArrayOop)array.resolve())->replace_if_null(index, o);
300 }
301 
302 oop CDSProtectionDomain::shared_protection_domain(int index) {
303   return ((objArrayOop)_shared_protection_domains.resolve())->obj_at(index);
304 }
305 
306 void CDSProtectionDomain::allocate_shared_protection_domain_array(int size, TRAPS) {
307   if (_shared_protection_domains.resolve() == nullptr) {
308     oop spd = oopFactory::new_objArray(
309         vmClasses::ProtectionDomain_klass(), size, CHECK);
310     _shared_protection_domains = OopHandle(Universe::vm_global(), spd);
311   }
312 }
313 
314 oop CDSProtectionDomain::shared_jar_url(int index) {
315   return ((objArrayOop)_shared_jar_urls.resolve())->obj_at(index);
316 }
317 
318 void CDSProtectionDomain::allocate_shared_jar_url_array(int size, TRAPS) {
319   if (_shared_jar_urls.resolve() == nullptr) {

 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *
 23  */
 24 
 25 #include "cds/aotClassLocation.hpp"
 26 #include "cds/cdsConfig.hpp"
 27 #include "cds/cdsProtectionDomain.hpp"
 28 #include "classfile/classLoader.hpp"
 29 #include "classfile/classLoaderData.inline.hpp"
 30 #include "classfile/classLoaderExt.hpp"
 31 #include "classfile/javaClasses.hpp"
 32 #include "classfile/moduleEntry.hpp"
 33 #include "classfile/systemDictionaryShared.hpp"
 34 #include "classfile/vmClasses.hpp"
 35 #include "classfile/vmSymbols.hpp"
 36 #include "memory/oopFactory.hpp"
 37 #include "memory/resourceArea.hpp"
 38 #include "memory/universe.hpp"
 39 #include "oops/instanceKlass.hpp"
 40 #include "oops/refArrayOop.hpp"
 41 #include "oops/symbol.hpp"
 42 #include "runtime/javaCalls.hpp"
 43 
 44 OopHandle CDSProtectionDomain::_shared_protection_domains;
 45 OopHandle CDSProtectionDomain::_shared_jar_urls;
 46 OopHandle CDSProtectionDomain::_shared_jar_manifests;
 47 
 48 // Initializes the java.lang.Package and java.security.ProtectionDomain objects associated with
 49 // the given InstanceKlass.
 50 // Returns the ProtectionDomain for the InstanceKlass.
 51 Handle CDSProtectionDomain::init_security_info(Handle class_loader, InstanceKlass* ik, PackageEntry* pkg_entry, TRAPS) {
 52   int index = ik->shared_classpath_index();
 53   assert(index >= 0, "Sanity");
 54   const AOTClassLocation* cl = AOTClassLocationConfig::runtime()->class_location_at(index);
 55   Symbol* class_name = ik->name();
 56 
 57   if (cl->is_modules_image()) {
 58     // For shared app/platform classes originated from the run-time image:
 59     //   The ProtectionDomains are cached in the corresponding ModuleEntries
 60     //   for fast access by the VM.

280                                location_string, CHECK_NH);
281         url = Handle(THREAD, result.get_oop());
282       }
283 
284       Handle pd = get_protection_domain_from_classloader(class_loader, url,
285                                                          CHECK_NH);
286       mod->set_shared_protection_domain(loader_data, pd);
287     }
288   }
289 
290   Handle protection_domain(THREAD, mod->shared_protection_domain());
291   assert(protection_domain.not_null(), "sanity");
292   return protection_domain;
293 }
294 
295 void CDSProtectionDomain::atomic_set_array_index(OopHandle array, int index, oop o) {
296   // Benign race condition:  array.obj_at(index) may already be filled in.
297   // The important thing here is that all threads pick up the same result.
298   // It doesn't matter which racing thread wins, as long as only one
299   // result is used by all threads, and all future queries.
300   refArrayOopDesc::cast(array.resolve())->replace_if_null(index, o);
301 }
302 
303 oop CDSProtectionDomain::shared_protection_domain(int index) {
304   return ((objArrayOop)_shared_protection_domains.resolve())->obj_at(index);
305 }
306 
307 void CDSProtectionDomain::allocate_shared_protection_domain_array(int size, TRAPS) {
308   if (_shared_protection_domains.resolve() == nullptr) {
309     oop spd = oopFactory::new_objArray(
310         vmClasses::ProtectionDomain_klass(), size, CHECK);
311     _shared_protection_domains = OopHandle(Universe::vm_global(), spd);
312   }
313 }
314 
315 oop CDSProtectionDomain::shared_jar_url(int index) {
316   return ((objArrayOop)_shared_jar_urls.resolve())->obj_at(index);
317 }
318 
319 void CDSProtectionDomain::allocate_shared_jar_url_array(int size, TRAPS) {
320   if (_shared_jar_urls.resolve() == nullptr) {
< prev index next >