< prev index next >

src/hotspot/share/classfile/systemDictionaryShared.cpp

Print this page
rev 58452 : imported patch pkg_name_from_class


 426     const char* path = FileMapInfo::shared_path_name(shared_path_index);
 427     Handle path_string = java_lang_String::create_from_str(path, CHECK_(url_h));
 428     Klass* classLoaders_klass =
 429         SystemDictionary::jdk_internal_loader_ClassLoaders_klass();
 430     JavaCalls::call_static(&result, classLoaders_klass,
 431                            vmSymbols::toFileURL_name(),
 432                            vmSymbols::toFileURL_signature(),
 433                            path_string, CHECK_(url_h));
 434 
 435     atomic_set_shared_jar_url(shared_path_index, (oop)result.get_jobject());
 436   }
 437 
 438   url_h = Handle(THREAD, shared_jar_url(shared_path_index));
 439   assert(url_h.not_null(), "sanity");
 440   return url_h;
 441 }
 442 
 443 Handle SystemDictionaryShared::get_package_name(Symbol* class_name, TRAPS) {
 444   ResourceMark rm(THREAD);
 445   Handle pkgname_string;
 446   char* pkgname = (char*) ClassLoader::package_from_name((const char*) class_name->as_C_string());
 447   if (pkgname != NULL) { // Package prefix found
 448     StringUtils::replace_no_expand(pkgname, "/", ".");
 449     pkgname_string = java_lang_String::create_from_str(pkgname,
 450                                                        CHECK_(pkgname_string));
 451   }
 452   return pkgname_string;
 453 }
 454 
 455 // Define Package for shared app classes from JAR file and also checks for
 456 // package sealing (all done in Java code)
 457 // See http://docs.oracle.com/javase/tutorial/deployment/jar/sealman.html
 458 void SystemDictionaryShared::define_shared_package(Symbol*  class_name,
 459                                                    Handle class_loader,
 460                                                    Handle manifest,
 461                                                    Handle url,
 462                                                    TRAPS) {
 463   assert(SystemDictionary::is_system_class_loader(class_loader()), "unexpected class loader");
 464   // get_package_name() returns a NULL handle if the class is in unnamed package
 465   Handle pkgname_string = get_package_name(class_name, CHECK);
 466   if (pkgname_string.not_null()) {
 467     Klass* app_classLoader_klass = SystemDictionary::jdk_internal_loader_ClassLoaders_AppClassLoader_klass();
 468     JavaValue result(T_OBJECT);


 585 // Initializes the java.lang.Package and java.security.ProtectionDomain objects associated with
 586 // the given InstanceKlass.
 587 // Returns the ProtectionDomain for the InstanceKlass.
 588 Handle SystemDictionaryShared::init_security_info(Handle class_loader, InstanceKlass* ik, TRAPS) {
 589   Handle pd;
 590 
 591   if (ik != NULL) {
 592     int index = ik->shared_classpath_index();
 593     assert(index >= 0, "Sanity");
 594     SharedClassPathEntry* ent = FileMapInfo::shared_path(index);
 595     Symbol* class_name = ik->name();
 596 
 597     if (ent->is_modules_image()) {
 598       // For shared app/platform classes originated from the run-time image:
 599       //   The ProtectionDomains are cached in the corresponding ModuleEntries
 600       //   for fast access by the VM.
 601       ResourceMark rm;
 602       ClassLoaderData *loader_data =
 603                 ClassLoaderData::class_loader_data(class_loader());
 604       PackageEntryTable* pkgEntryTable = loader_data->packages();
 605       TempNewSymbol pkg_name = InstanceKlass::package_from_name(class_name, CHECK_(pd));
 606       if (pkg_name != NULL) {
 607         PackageEntry* pkg_entry = pkgEntryTable->lookup_only(pkg_name);
 608         if (pkg_entry != NULL) {
 609           ModuleEntry* mod_entry = pkg_entry->module();
 610           pd = get_shared_protection_domain(class_loader, mod_entry, THREAD);
 611           define_shared_package(class_name, class_loader, mod_entry, CHECK_(pd));
 612         }
 613       }
 614     } else {
 615       // For shared app/platform classes originated from JAR files on the class path:
 616       //   Each of the 3 SystemDictionaryShared::_shared_xxx arrays has the same length
 617       //   as the shared classpath table in the shared archive (see
 618       //   FileMap::_shared_path_table in filemap.hpp for details).
 619       //
 620       //   If a shared InstanceKlass k is loaded from the class path, let
 621       //
 622       //     index = k->shared_classpath_index():
 623       //
 624       //   FileMap::_shared_path_table[index] identifies the JAR file that contains k.
 625       //




 426     const char* path = FileMapInfo::shared_path_name(shared_path_index);
 427     Handle path_string = java_lang_String::create_from_str(path, CHECK_(url_h));
 428     Klass* classLoaders_klass =
 429         SystemDictionary::jdk_internal_loader_ClassLoaders_klass();
 430     JavaCalls::call_static(&result, classLoaders_klass,
 431                            vmSymbols::toFileURL_name(),
 432                            vmSymbols::toFileURL_signature(),
 433                            path_string, CHECK_(url_h));
 434 
 435     atomic_set_shared_jar_url(shared_path_index, (oop)result.get_jobject());
 436   }
 437 
 438   url_h = Handle(THREAD, shared_jar_url(shared_path_index));
 439   assert(url_h.not_null(), "sanity");
 440   return url_h;
 441 }
 442 
 443 Handle SystemDictionaryShared::get_package_name(Symbol* class_name, TRAPS) {
 444   ResourceMark rm(THREAD);
 445   Handle pkgname_string;
 446   Symbol* pkg = InstanceKlass::package_from_name(class_name);
 447   if (pkg != NULL) { // Package prefix found
 448     const char* pkgname = pkg->as_klass_external_name();
 449     pkgname_string = java_lang_String::create_from_str(pkgname,
 450                                                        CHECK_(pkgname_string));
 451   }
 452   return pkgname_string;
 453 }
 454 
 455 // Define Package for shared app classes from JAR file and also checks for
 456 // package sealing (all done in Java code)
 457 // See http://docs.oracle.com/javase/tutorial/deployment/jar/sealman.html
 458 void SystemDictionaryShared::define_shared_package(Symbol*  class_name,
 459                                                    Handle class_loader,
 460                                                    Handle manifest,
 461                                                    Handle url,
 462                                                    TRAPS) {
 463   assert(SystemDictionary::is_system_class_loader(class_loader()), "unexpected class loader");
 464   // get_package_name() returns a NULL handle if the class is in unnamed package
 465   Handle pkgname_string = get_package_name(class_name, CHECK);
 466   if (pkgname_string.not_null()) {
 467     Klass* app_classLoader_klass = SystemDictionary::jdk_internal_loader_ClassLoaders_AppClassLoader_klass();
 468     JavaValue result(T_OBJECT);


 585 // Initializes the java.lang.Package and java.security.ProtectionDomain objects associated with
 586 // the given InstanceKlass.
 587 // Returns the ProtectionDomain for the InstanceKlass.
 588 Handle SystemDictionaryShared::init_security_info(Handle class_loader, InstanceKlass* ik, TRAPS) {
 589   Handle pd;
 590 
 591   if (ik != NULL) {
 592     int index = ik->shared_classpath_index();
 593     assert(index >= 0, "Sanity");
 594     SharedClassPathEntry* ent = FileMapInfo::shared_path(index);
 595     Symbol* class_name = ik->name();
 596 
 597     if (ent->is_modules_image()) {
 598       // For shared app/platform classes originated from the run-time image:
 599       //   The ProtectionDomains are cached in the corresponding ModuleEntries
 600       //   for fast access by the VM.
 601       ResourceMark rm;
 602       ClassLoaderData *loader_data =
 603                 ClassLoaderData::class_loader_data(class_loader());
 604       PackageEntryTable* pkgEntryTable = loader_data->packages();
 605       TempNewSymbol pkg_name = InstanceKlass::package_from_name(class_name);
 606       if (pkg_name != NULL) {
 607         PackageEntry* pkg_entry = pkgEntryTable->lookup_only(pkg_name);
 608         if (pkg_entry != NULL) {
 609           ModuleEntry* mod_entry = pkg_entry->module();
 610           pd = get_shared_protection_domain(class_loader, mod_entry, THREAD);
 611           define_shared_package(class_name, class_loader, mod_entry, CHECK_(pd));
 612         }
 613       }
 614     } else {
 615       // For shared app/platform classes originated from JAR files on the class path:
 616       //   Each of the 3 SystemDictionaryShared::_shared_xxx arrays has the same length
 617       //   as the shared classpath table in the shared archive (see
 618       //   FileMap::_shared_path_table in filemap.hpp for details).
 619       //
 620       //   If a shared InstanceKlass k is loaded from the class path, let
 621       //
 622       //     index = k->shared_classpath_index():
 623       //
 624       //   FileMap::_shared_path_table[index] identifies the JAR file that contains k.
 625       //


< prev index next >