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 #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/javaClasses.hpp"
31 #include "classfile/moduleEntry.hpp"
32 #include "classfile/systemDictionaryShared.hpp"
33 #include "classfile/vmClasses.hpp"
34 #include "classfile/vmSymbols.hpp"
35 #include "memory/oopFactory.hpp"
36 #include "memory/resourceArea.hpp"
37 #include "memory/universe.hpp"
38 #include "oops/instanceKlass.hpp"
39 #include "oops/symbol.hpp"
40 #include "runtime/javaCalls.hpp"
41
42 OopHandle CDSProtectionDomain::_shared_protection_domains;
43 OopHandle CDSProtectionDomain::_shared_jar_urls;
44 OopHandle CDSProtectionDomain::_shared_jar_manifests;
45
46 // Initializes the java.lang.Package and java.security.ProtectionDomain objects associated with
47 // the given InstanceKlass.
48 // Returns the ProtectionDomain for the InstanceKlass.
49 Handle CDSProtectionDomain::init_security_info(Handle class_loader, InstanceKlass* ik, PackageEntry* pkg_entry, TRAPS) {
50 int index = ik->shared_classpath_index();
51 assert(index >= 0, "Sanity");
52 const AOTClassLocation* cl = AOTClassLocationConfig::runtime()->class_location_at(index);
53 Symbol* class_name = ik->name();
54
55 if (cl->is_modules_image()) {
56 // For shared app/platform classes originated from the run-time image:
57 // The ProtectionDomains are cached in the corresponding ModuleEntries
58 // for fast access by the VM.
277 location_string, CHECK_NH);
278 url = Handle(THREAD, result.get_oop());
279 }
280
281 Handle pd = get_protection_domain_from_classloader(class_loader, url,
282 CHECK_NH);
283 mod->set_shared_protection_domain(loader_data, pd);
284 }
285 }
286
287 Handle protection_domain(THREAD, mod->shared_protection_domain());
288 assert(protection_domain.not_null(), "sanity");
289 return protection_domain;
290 }
291
292 void CDSProtectionDomain::atomic_set_array_index(OopHandle array, int index, oop o) {
293 // Benign race condition: array.obj_at(index) may already be filled in.
294 // The important thing here is that all threads pick up the same result.
295 // It doesn't matter which racing thread wins, as long as only one
296 // result is used by all threads, and all future queries.
297 ((objArrayOop)array.resolve())->replace_if_null(index, o);
298 }
299
300 oop CDSProtectionDomain::shared_protection_domain(int index) {
301 return ((objArrayOop)_shared_protection_domains.resolve())->obj_at(index);
302 }
303
304 void CDSProtectionDomain::allocate_shared_protection_domain_array(int size, TRAPS) {
305 if (_shared_protection_domains.resolve() == nullptr) {
306 oop spd = oopFactory::new_objArray(
307 vmClasses::ProtectionDomain_klass(), size, CHECK);
308 _shared_protection_domains = OopHandle(Universe::vm_global(), spd);
309 }
310 }
311
312 oop CDSProtectionDomain::shared_jar_url(int index) {
313 return ((objArrayOop)_shared_jar_urls.resolve())->obj_at(index);
314 }
315
316 void CDSProtectionDomain::allocate_shared_jar_url_array(int size, TRAPS) {
317 if (_shared_jar_urls.resolve() == nullptr) {
|
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 #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/javaClasses.hpp"
31 #include "classfile/moduleEntry.hpp"
32 #include "classfile/systemDictionaryShared.hpp"
33 #include "classfile/vmClasses.hpp"
34 #include "classfile/vmSymbols.hpp"
35 #include "memory/oopFactory.hpp"
36 #include "memory/resourceArea.hpp"
37 #include "memory/universe.hpp"
38 #include "oops/instanceKlass.hpp"
39 #include "oops/refArrayOop.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.
278 location_string, CHECK_NH);
279 url = Handle(THREAD, result.get_oop());
280 }
281
282 Handle pd = get_protection_domain_from_classloader(class_loader, url,
283 CHECK_NH);
284 mod->set_shared_protection_domain(loader_data, pd);
285 }
286 }
287
288 Handle protection_domain(THREAD, mod->shared_protection_domain());
289 assert(protection_domain.not_null(), "sanity");
290 return protection_domain;
291 }
292
293 void CDSProtectionDomain::atomic_set_array_index(OopHandle array, int index, oop o) {
294 // Benign race condition: array.obj_at(index) may already be filled in.
295 // The important thing here is that all threads pick up the same result.
296 // It doesn't matter which racing thread wins, as long as only one
297 // result is used by all threads, and all future queries.
298 refArrayOopDesc::cast(array.resolve())->replace_if_null(index, o);
299 }
300
301 oop CDSProtectionDomain::shared_protection_domain(int index) {
302 return ((objArrayOop)_shared_protection_domains.resolve())->obj_at(index);
303 }
304
305 void CDSProtectionDomain::allocate_shared_protection_domain_array(int size, TRAPS) {
306 if (_shared_protection_domains.resolve() == nullptr) {
307 oop spd = oopFactory::new_objArray(
308 vmClasses::ProtectionDomain_klass(), size, CHECK);
309 _shared_protection_domains = OopHandle(Universe::vm_global(), spd);
310 }
311 }
312
313 oop CDSProtectionDomain::shared_jar_url(int index) {
314 return ((objArrayOop)_shared_jar_urls.resolve())->obj_at(index);
315 }
316
317 void CDSProtectionDomain::allocate_shared_jar_url_array(int size, TRAPS) {
318 if (_shared_jar_urls.resolve() == nullptr) {
|