< prev index next >

src/share/vm/classfile/classLoader.cpp

Print this page




 123 PerfCounter*    ClassLoader::_perf_sys_class_lookup_time = NULL;
 124 PerfCounter*    ClassLoader::_perf_shared_classload_time = NULL;
 125 PerfCounter*    ClassLoader::_perf_sys_classload_time = NULL;
 126 PerfCounter*    ClassLoader::_perf_app_classload_time = NULL;
 127 PerfCounter*    ClassLoader::_perf_app_classload_selftime = NULL;
 128 PerfCounter*    ClassLoader::_perf_app_classload_count = NULL;
 129 PerfCounter*    ClassLoader::_perf_define_appclasses = NULL;
 130 PerfCounter*    ClassLoader::_perf_define_appclass_time = NULL;
 131 PerfCounter*    ClassLoader::_perf_define_appclass_selftime = NULL;
 132 PerfCounter*    ClassLoader::_perf_app_classfile_bytes_read = NULL;
 133 PerfCounter*    ClassLoader::_perf_sys_classfile_bytes_read = NULL;
 134 PerfCounter*    ClassLoader::_sync_systemLoaderLockContentionRate = NULL;
 135 PerfCounter*    ClassLoader::_sync_nonSystemLoaderLockContentionRate = NULL;
 136 PerfCounter*    ClassLoader::_sync_JVMFindLoadedClassLockFreeCounter = NULL;
 137 PerfCounter*    ClassLoader::_sync_JVMDefineClassLockFreeCounter = NULL;
 138 PerfCounter*    ClassLoader::_sync_JNIDefineClassLockFreeCounter = NULL;
 139 PerfCounter*    ClassLoader::_unsafe_defineClassCallCounter = NULL;
 140 PerfCounter*    ClassLoader::_isUnsyncloadClass = NULL;
 141 PerfCounter*    ClassLoader::_load_instance_class_failCounter = NULL;
 142 
 143 GrowableArray<ModuleClassPathList*>* ClassLoader::_xpatch_entries = NULL;
 144 ClassPathEntry* ClassLoader::_first_entry        = NULL;
 145 ClassPathEntry* ClassLoader::_last_entry         = NULL;
 146 int             ClassLoader::_num_entries        = 0;
 147 ClassPathEntry* ClassLoader::_first_append_entry = NULL;
 148 bool            ClassLoader::_has_jimage = false;
 149 #if INCLUDE_CDS
 150 GrowableArray<char*>* ClassLoader::_boot_modules_array = NULL;
 151 GrowableArray<char*>* ClassLoader::_platform_modules_array = NULL;
 152 SharedPathsMiscInfo* ClassLoader::_shared_paths_misc_info = NULL;
 153 #endif
 154 
 155 // helper routines
 156 bool string_starts_with(const char* str, const char* str_to_find) {
 157   size_t str_len = strlen(str);
 158   size_t str_to_find_len = strlen(str_to_find);
 159   if (str_to_find_len > str_len) {
 160     return false;
 161   }
 162   return (strncmp(str, str_to_find, str_to_find_len) == 0);
 163 }


 669   setup_search_path(sys_class_path, true);
 670 }
 671 
 672 #if INCLUDE_CDS
 673 int ClassLoader::get_shared_paths_misc_info_size() {
 674   return _shared_paths_misc_info->get_used_bytes();
 675 }
 676 
 677 void* ClassLoader::get_shared_paths_misc_info() {
 678   return _shared_paths_misc_info->buffer();
 679 }
 680 
 681 bool ClassLoader::check_shared_paths_misc_info(void *buf, int size) {
 682   SharedPathsMiscInfo* checker = SharedClassUtil::allocate_shared_paths_misc_info((char*)buf, size);
 683   bool result = checker->check();
 684   delete checker;
 685   return result;
 686 }
 687 #endif
 688 
 689 // Construct the array of module/path pairs as specified to -Xpatch
 690 // for the boot loader to search ahead of the jimage, if the class being
 691 // loaded is defined to a module that has been specified to -Xpatch.
 692 void ClassLoader::setup_xpatch_entries() {
 693   Thread* THREAD = Thread::current();
 694   GrowableArray<ModuleXPatchPath*>* xpatch_args = Arguments::get_xpatchprefix();
 695   int num_of_entries = xpatch_args->length();
 696 
 697   // Set up the boot loader's xpatch_entries list
 698   _xpatch_entries = new (ResourceObj::C_HEAP, mtModule) GrowableArray<ModuleClassPathList*>(num_of_entries, true);
 699 
 700   for (int i = 0; i < num_of_entries; i++) {
 701     const char* module_name = (xpatch_args->at(i))->module_name();
 702     Symbol* const module_sym = SymbolTable::lookup(module_name, (int)strlen(module_name), CHECK);
 703     assert(module_sym != NULL, "Failed to obtain Symbol for module name");
 704     ModuleClassPathList* module_cpl = new ModuleClassPathList(module_sym);
 705 
 706     char* class_path = (xpatch_args->at(i))->path_string();
 707     int len = (int)strlen(class_path);
 708     int end = 0;
 709     // Iterate over the module's class path entries
 710     for (int start = 0; start < len; start = end) {
 711       while (class_path[end] && class_path[end] != os::path_separator()[0]) {
 712         end++;
 713       }
 714       EXCEPTION_MARK;
 715       ResourceMark rm(THREAD);
 716       char* path = NEW_RESOURCE_ARRAY(char, end - start + 1);
 717       strncpy(path, &class_path[start], end - start);
 718       path[end - start] = '\0';
 719 
 720       struct stat st;
 721       if (os::stat(path, &st) == 0) {
 722         // File or directory found
 723         Thread* THREAD = Thread::current();
 724         ClassPathEntry* new_entry = create_class_path_entry(path, &st, false, false, CHECK);
 725         // If the path specification is valid, enter it into this module's list
 726         if (new_entry != NULL) {
 727           module_cpl->add_to_list(new_entry);
 728         }
 729       }
 730 
 731       while (class_path[end] == os::path_separator()[0]) {
 732         end++;
 733       }
 734     }
 735 
 736     // Record the module into the list of -Xpatch entries only if
 737     // valid ClassPathEntrys have been created
 738     if (module_cpl->module_first_entry() != NULL) {
 739       _xpatch_entries->push(module_cpl);
 740     }
 741   }
 742 }
 743 
 744 void ClassLoader::setup_search_path(const char *class_path, bool bootstrap_search) {
 745   int offset = 0;
 746   int len = (int)strlen(class_path);
 747   int end = 0;
 748   bool mark_append_entry = false;
 749 
 750   // Iterate over class path entries
 751   for (int start = 0; start < len; start = end) {
 752     while (class_path[end] && class_path[end] != os::path_separator()[0]) {
 753       end++;
 754     }
 755     EXCEPTION_MARK;
 756     ResourceMark rm(THREAD);
 757     mark_append_entry = (mark_append_entry ||
 758       (bootstrap_search && (start == Arguments::bootclassloader_append_index())));
 759     char* path = NEW_RESOURCE_ARRAY(char, end - start + 1);


 958       ClassLoaderExt::add_class_path_entry(path, check_for_duplicates, new_entry, prepend_entry);
 959       if (mark_append_entry) {
 960         set_first_append_entry(new_entry);
 961       }
 962     }
 963     return true;
 964   } else {
 965 #if INCLUDE_CDS
 966     if (DumpSharedSpaces) {
 967       _shared_paths_misc_info->add_nonexist_path(path);
 968     }
 969 #endif
 970     return false;
 971   }
 972 }
 973 
 974 void ClassLoader::print_bootclasspath() {
 975   ClassPathEntry* e;
 976   tty->print("[bootclasspath= ");
 977 
 978   // Print -Xpatch module/path specifications first
 979   if (_xpatch_entries != NULL) {
 980     ResourceMark rm;
 981     int num_of_entries = _xpatch_entries->length();
 982     for (int i = 0; i < num_of_entries; i++) {
 983       ModuleClassPathList* mpl = _xpatch_entries->at(i);
 984       tty->print("%s=", mpl->module_name()->as_C_string());
 985       e = mpl->module_first_entry();
 986       while (e != NULL) {
 987         tty->print("%s", e->name());
 988         e = e->next();
 989         if (e != NULL) {
 990           tty->print("%s", os::path_separator());
 991         }
 992       }
 993       tty->print(" ;");
 994     }
 995   }
 996 
 997   e = _first_entry;
 998   while (e != NULL) {
 999     tty->print("%s ;", e->name());
1000     e = e->next();
1001   }
1002   tty->print_cr("]");
1003 }


1305   ResourceMark rm(THREAD);
1306   HandleMark hm(THREAD);
1307 
1308   const char* const class_name = name->as_C_string();
1309 
1310   EventMark m("loading class %s", class_name);
1311   ThreadProfilerMark tpm(ThreadProfilerMark::classLoaderRegion);
1312 
1313   const char* const file_name = file_name_for_class_name(class_name,
1314                                                          name->utf8_length());
1315   assert(file_name != NULL, "invariant");
1316 
1317   ClassLoaderExt::Context context(class_name, file_name, THREAD);
1318 
1319   // Lookup stream for parsing .class file
1320   ClassFileStream* stream = NULL;
1321   s2 classpath_index = 0;
1322   ClassPathEntry* e = NULL;
1323 
1324   // If DumpSharedSpaces is true, boot loader visibility boundaries are set
1325   // to be _first_entry to the end (all path entries). No -Xpatch entries are
1326   // included since CDS and AppCDS are not supported if -Xpatch is specified.
1327   //
1328   // If search_append_only is true, boot loader visibility boundaries are
1329   // set to be _first_append_entry to the end. This includes:
1330   //   [-Xbootclasspath/a]; [jvmti appended entries]
1331   //
1332   // If both DumpSharedSpaces and search_append_only are false, boot loader
1333   // visibility boundaries are set to be _first_entry to the entry before
1334   // the _first_append_entry.  This would include:
1335   //   [-Xpatch:<module>=<file>(<pathsep><file>)*];  [exploded build | jimage]
1336   //
1337   // DumpSharedSpaces and search_append_only are mutually exclusive and cannot
1338   // be true at the same time.
1339   assert(!(DumpSharedSpaces && search_append_only), "DumpSharedSpaces and search_append_only are both true");
1340 
1341   // Load Attempt #1: -Xpatch
1342   // Determine the class' defining module.  If it appears in the _xpatch_entries,
1343   // attempt to load the class from those locations specific to the module.
1344   // Note: The -Xpatch entries are never searched if the boot loader's
1345   //       visibility boundary is limited to only searching the append entries.
1346   if (_xpatch_entries != NULL && !search_append_only && !DumpSharedSpaces) {
1347     // Find the module in the boot loader's module entry table
1348     PackageEntry* pkg_entry = get_package_entry(class_name, ClassLoaderData::the_null_class_loader_data(), THREAD);
1349     ModuleEntry* mod_entry = (pkg_entry != NULL) ? pkg_entry->module() : NULL;
1350 
1351     // If the module system has not defined java.base yet, then
1352     // classes loaded are assumed to be defined to java.base.
1353     // When java.base is eventually defined by the module system,
1354     // all packages of classes that have been previously loaded
1355     // are verified in ModuleEntryTable::verify_javabase_packages().
1356     if (!Universe::is_module_initialized() &&
1357         !ModuleEntryTable::javabase_defined() &&
1358         mod_entry == NULL) {
1359       mod_entry = ModuleEntryTable::javabase_module();
1360     }
1361 
1362     // The module must be a named module
1363     if (mod_entry != NULL && mod_entry->is_named()) {
1364       int num_of_entries = _xpatch_entries->length();
1365       const Symbol* class_module_name = mod_entry->name();
1366 
1367       // Loop through all the xpatch entries looking for module
1368       for (int i = 0; i < num_of_entries; i++) {
1369         ModuleClassPathList* module_cpl = _xpatch_entries->at(i);
1370         Symbol* module_cpl_name = module_cpl->module_name();
1371 
1372         if (module_cpl_name->fast_compare(class_module_name) == 0) {
1373           // Class' module has been located, attempt to load
1374           // the class from the module's ClassPathEntry list.
1375           e = module_cpl->module_first_entry();
1376           while (e != NULL) {
1377             stream = e->open_stream(file_name, CHECK_NULL);
1378             // No context.check is required since both CDS
1379             // and AppCDS are turned off if -Xpatch is specified.
1380             if (NULL != stream) {
1381               break;
1382             }
1383             e = e->next();
1384           }
1385           // If the module was located in the xpatch entries, break out
1386           // even if the class was not located successfully from that module's
1387           // ClassPathEntry list. There will not be another valid entry for
1388           // that module in the _xpatch_entries array.
1389           break;
1390         }
1391       }
1392     }
1393   }
1394 
1395   // Load Attempt #2: [exploded build | jimage]
1396   if (!search_append_only && (NULL == stream)) {
1397     e = _first_entry;
1398     while ((e != NULL) && (e != _first_append_entry)) {
1399       stream = e->open_stream(file_name, CHECK_NULL);
1400       if (!context.check(stream, classpath_index)) {
1401         return NULL;
1402       }
1403       if (NULL != stream) {
1404         break;
1405       }
1406       e = e->next();
1407       ++classpath_index;
1408     }


1581 jlong ClassLoader::class_link_time_ms() {
1582   return UsePerfData ?
1583     Management::ticks_to_ms(_perf_class_link_time->get_value()) : -1;
1584 }
1585 
1586 int ClassLoader::compute_Object_vtable() {
1587   // hardwired for JDK1.2 -- would need to duplicate class file parsing
1588   // code to determine actual value from file
1589   // Would be value '11' if finals were in vtable
1590   int JDK_1_2_Object_vtable_size = 5;
1591   return JDK_1_2_Object_vtable_size * vtableEntry::size();
1592 }
1593 
1594 
1595 void classLoader_init1() {
1596   ClassLoader::initialize();
1597 }
1598 
1599 // Complete the ClassPathEntry setup for the boot loader
1600 void classLoader_init2() {
1601   // Setup the list of module/path pairs for -Xpatch processing
1602   // This must be done after the SymbolTable is created in order
1603   // to use fast_compare on module names instead of a string compare.
1604   if (Arguments::get_xpatchprefix() != NULL) {
1605     ClassLoader::setup_xpatch_entries();
1606   }
1607 
1608   // Determine if this is an exploded build
1609   ClassLoader::set_has_jimage();
1610 }
1611 
1612 
1613 bool ClassLoader::get_canonical_path(const char* orig, char* out, int len) {
1614   assert(orig != NULL && out != NULL && len > 0, "bad arguments");
1615   if (CanonicalizeEntry != NULL) {
1616     JavaThread* THREAD = JavaThread::current();
1617     JNIEnv* env = THREAD->jni_environment();
1618     ResourceMark rm(THREAD);
1619 
1620     // os::native_path writes into orig_copy
1621     char* orig_copy = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, strlen(orig)+1);
1622     strcpy(orig_copy, orig);
1623     if ((CanonicalizeEntry)(env, os::native_path(orig_copy), out, len) < 0) {
1624       return false;
1625     }


1641   // Get module entry table
1642   ModuleEntryTable* null_cld_modules = null_cld->modules();
1643   if (null_cld_modules == NULL) {
1644     vm_exit_during_initialization("No ModuleEntryTable for the boot class loader");
1645   }
1646 
1647   {
1648     MutexLocker ml(Module_lock, THREAD);
1649     ModuleEntry* jb_module = null_cld_modules->locked_create_entry_or_null(Handle(NULL), vmSymbols::java_base(), NULL, NULL, null_cld);
1650     if (jb_module == NULL) {
1651       vm_exit_during_initialization("Unable to create ModuleEntry for java.base");
1652     }
1653     ModuleEntryTable::set_javabase_module(jb_module);
1654   }
1655 }
1656 
1657 void ClassLoader::set_has_jimage() {
1658   // Determine if this is an exploded build. When looking for
1659   // the jimage file, only search the piece of the boot
1660   // loader's boot class path which contains [exploded build | jimage].
1661   // Do not search the boot loader's xpatch entries or append path.
1662   ClassPathEntry* e = _first_entry;
1663   ClassPathEntry* last_e = _first_append_entry;
1664   while ((e != NULL) && (e != last_e)) {
1665     JImageFile *jimage = e->jimage();
1666     if (jimage != NULL && e->is_jrt()) {
1667       _has_jimage = true;
1668 #if INCLUDE_CDS
1669       ClassLoader::initialize_module_loader_map(jimage);
1670 #endif
1671       return;
1672     }
1673     e = e->next();
1674   }
1675 }
1676 
1677 #ifndef PRODUCT
1678 
1679 // CompileTheWorld
1680 //
1681 // Iterates over all class path entries and forces compilation of all methods




 123 PerfCounter*    ClassLoader::_perf_sys_class_lookup_time = NULL;
 124 PerfCounter*    ClassLoader::_perf_shared_classload_time = NULL;
 125 PerfCounter*    ClassLoader::_perf_sys_classload_time = NULL;
 126 PerfCounter*    ClassLoader::_perf_app_classload_time = NULL;
 127 PerfCounter*    ClassLoader::_perf_app_classload_selftime = NULL;
 128 PerfCounter*    ClassLoader::_perf_app_classload_count = NULL;
 129 PerfCounter*    ClassLoader::_perf_define_appclasses = NULL;
 130 PerfCounter*    ClassLoader::_perf_define_appclass_time = NULL;
 131 PerfCounter*    ClassLoader::_perf_define_appclass_selftime = NULL;
 132 PerfCounter*    ClassLoader::_perf_app_classfile_bytes_read = NULL;
 133 PerfCounter*    ClassLoader::_perf_sys_classfile_bytes_read = NULL;
 134 PerfCounter*    ClassLoader::_sync_systemLoaderLockContentionRate = NULL;
 135 PerfCounter*    ClassLoader::_sync_nonSystemLoaderLockContentionRate = NULL;
 136 PerfCounter*    ClassLoader::_sync_JVMFindLoadedClassLockFreeCounter = NULL;
 137 PerfCounter*    ClassLoader::_sync_JVMDefineClassLockFreeCounter = NULL;
 138 PerfCounter*    ClassLoader::_sync_JNIDefineClassLockFreeCounter = NULL;
 139 PerfCounter*    ClassLoader::_unsafe_defineClassCallCounter = NULL;
 140 PerfCounter*    ClassLoader::_isUnsyncloadClass = NULL;
 141 PerfCounter*    ClassLoader::_load_instance_class_failCounter = NULL;
 142 
 143 GrowableArray<ModuleClassPathList*>* ClassLoader::_patch_mod_entries = NULL;
 144 ClassPathEntry* ClassLoader::_first_entry        = NULL;
 145 ClassPathEntry* ClassLoader::_last_entry         = NULL;
 146 int             ClassLoader::_num_entries        = 0;
 147 ClassPathEntry* ClassLoader::_first_append_entry = NULL;
 148 bool            ClassLoader::_has_jimage = false;
 149 #if INCLUDE_CDS
 150 GrowableArray<char*>* ClassLoader::_boot_modules_array = NULL;
 151 GrowableArray<char*>* ClassLoader::_platform_modules_array = NULL;
 152 SharedPathsMiscInfo* ClassLoader::_shared_paths_misc_info = NULL;
 153 #endif
 154 
 155 // helper routines
 156 bool string_starts_with(const char* str, const char* str_to_find) {
 157   size_t str_len = strlen(str);
 158   size_t str_to_find_len = strlen(str_to_find);
 159   if (str_to_find_len > str_len) {
 160     return false;
 161   }
 162   return (strncmp(str, str_to_find, str_to_find_len) == 0);
 163 }


 669   setup_search_path(sys_class_path, true);
 670 }
 671 
 672 #if INCLUDE_CDS
 673 int ClassLoader::get_shared_paths_misc_info_size() {
 674   return _shared_paths_misc_info->get_used_bytes();
 675 }
 676 
 677 void* ClassLoader::get_shared_paths_misc_info() {
 678   return _shared_paths_misc_info->buffer();
 679 }
 680 
 681 bool ClassLoader::check_shared_paths_misc_info(void *buf, int size) {
 682   SharedPathsMiscInfo* checker = SharedClassUtil::allocate_shared_paths_misc_info((char*)buf, size);
 683   bool result = checker->check();
 684   delete checker;
 685   return result;
 686 }
 687 #endif
 688 
 689 // Construct the array of module/path pairs as specified to --patch-module
 690 // for the boot loader to search ahead of the jimage, if the class being
 691 // loaded is defined to a module that has been specified to --patch-module.
 692 void ClassLoader::setup_patch_mod_entries() {
 693   Thread* THREAD = Thread::current();
 694   GrowableArray<ModulePatchPath*>* patch_mod_args = Arguments::get_patch_mod_prefix();
 695   int num_of_entries = patch_mod_args->length();
 696 
 697   // Set up the boot loader's patch_mod_entries list
 698   _patch_mod_entries = new (ResourceObj::C_HEAP, mtModule) GrowableArray<ModuleClassPathList*>(num_of_entries, true);
 699 
 700   for (int i = 0; i < num_of_entries; i++) {
 701     const char* module_name = (patch_mod_args->at(i))->module_name();
 702     Symbol* const module_sym = SymbolTable::lookup(module_name, (int)strlen(module_name), CHECK);
 703     assert(module_sym != NULL, "Failed to obtain Symbol for module name");
 704     ModuleClassPathList* module_cpl = new ModuleClassPathList(module_sym);
 705 
 706     char* class_path = (patch_mod_args->at(i))->path_string();
 707     int len = (int)strlen(class_path);
 708     int end = 0;
 709     // Iterate over the module's class path entries
 710     for (int start = 0; start < len; start = end) {
 711       while (class_path[end] && class_path[end] != os::path_separator()[0]) {
 712         end++;
 713       }
 714       EXCEPTION_MARK;
 715       ResourceMark rm(THREAD);
 716       char* path = NEW_RESOURCE_ARRAY(char, end - start + 1);
 717       strncpy(path, &class_path[start], end - start);
 718       path[end - start] = '\0';
 719 
 720       struct stat st;
 721       if (os::stat(path, &st) == 0) {
 722         // File or directory found
 723         Thread* THREAD = Thread::current();
 724         ClassPathEntry* new_entry = create_class_path_entry(path, &st, false, false, CHECK);
 725         // If the path specification is valid, enter it into this module's list
 726         if (new_entry != NULL) {
 727           module_cpl->add_to_list(new_entry);
 728         }
 729       }
 730 
 731       while (class_path[end] == os::path_separator()[0]) {
 732         end++;
 733       }
 734     }
 735 
 736     // Record the module into the list of --patch-module entries only if
 737     // valid ClassPathEntrys have been created
 738     if (module_cpl->module_first_entry() != NULL) {
 739       _patch_mod_entries->push(module_cpl);
 740     }
 741   }
 742 }
 743 
 744 void ClassLoader::setup_search_path(const char *class_path, bool bootstrap_search) {
 745   int offset = 0;
 746   int len = (int)strlen(class_path);
 747   int end = 0;
 748   bool mark_append_entry = false;
 749 
 750   // Iterate over class path entries
 751   for (int start = 0; start < len; start = end) {
 752     while (class_path[end] && class_path[end] != os::path_separator()[0]) {
 753       end++;
 754     }
 755     EXCEPTION_MARK;
 756     ResourceMark rm(THREAD);
 757     mark_append_entry = (mark_append_entry ||
 758       (bootstrap_search && (start == Arguments::bootclassloader_append_index())));
 759     char* path = NEW_RESOURCE_ARRAY(char, end - start + 1);


 958       ClassLoaderExt::add_class_path_entry(path, check_for_duplicates, new_entry, prepend_entry);
 959       if (mark_append_entry) {
 960         set_first_append_entry(new_entry);
 961       }
 962     }
 963     return true;
 964   } else {
 965 #if INCLUDE_CDS
 966     if (DumpSharedSpaces) {
 967       _shared_paths_misc_info->add_nonexist_path(path);
 968     }
 969 #endif
 970     return false;
 971   }
 972 }
 973 
 974 void ClassLoader::print_bootclasspath() {
 975   ClassPathEntry* e;
 976   tty->print("[bootclasspath= ");
 977 
 978   // Print --patch-module module/path specifications first
 979   if (_patch_mod_entries != NULL) {
 980     ResourceMark rm;
 981     int num_of_entries = _patch_mod_entries->length();
 982     for (int i = 0; i < num_of_entries; i++) {
 983       ModuleClassPathList* mpl = _patch_mod_entries->at(i);
 984       tty->print("%s=", mpl->module_name()->as_C_string());
 985       e = mpl->module_first_entry();
 986       while (e != NULL) {
 987         tty->print("%s", e->name());
 988         e = e->next();
 989         if (e != NULL) {
 990           tty->print("%s", os::path_separator());
 991         }
 992       }
 993       tty->print(" ;");
 994     }
 995   }
 996 
 997   e = _first_entry;
 998   while (e != NULL) {
 999     tty->print("%s ;", e->name());
1000     e = e->next();
1001   }
1002   tty->print_cr("]");
1003 }


1305   ResourceMark rm(THREAD);
1306   HandleMark hm(THREAD);
1307 
1308   const char* const class_name = name->as_C_string();
1309 
1310   EventMark m("loading class %s", class_name);
1311   ThreadProfilerMark tpm(ThreadProfilerMark::classLoaderRegion);
1312 
1313   const char* const file_name = file_name_for_class_name(class_name,
1314                                                          name->utf8_length());
1315   assert(file_name != NULL, "invariant");
1316 
1317   ClassLoaderExt::Context context(class_name, file_name, THREAD);
1318 
1319   // Lookup stream for parsing .class file
1320   ClassFileStream* stream = NULL;
1321   s2 classpath_index = 0;
1322   ClassPathEntry* e = NULL;
1323 
1324   // If DumpSharedSpaces is true, boot loader visibility boundaries are set
1325   // to be _first_entry to the end (all path entries). No --patch-module entries are
1326   // included since CDS and AppCDS are not supported if --patch-module is specified.
1327   //
1328   // If search_append_only is true, boot loader visibility boundaries are
1329   // set to be _first_append_entry to the end. This includes:
1330   //   [-Xbootclasspath/a]; [jvmti appended entries]
1331   //
1332   // If both DumpSharedSpaces and search_append_only are false, boot loader
1333   // visibility boundaries are set to be _first_entry to the entry before
1334   // the _first_append_entry.  This would include:
1335   //   [--patch-module=<module>=<file>(<pathsep><file>)*];  [exploded build | jimage]
1336   //
1337   // DumpSharedSpaces and search_append_only are mutually exclusive and cannot
1338   // be true at the same time.
1339   assert(!(DumpSharedSpaces && search_append_only), "DumpSharedSpaces and search_append_only are both true");
1340 
1341   // Load Attempt #1: --patch-module
1342   // Determine the class' defining module.  If it appears in the _patch_mod_entries,
1343   // attempt to load the class from those locations specific to the module.
1344   // Note: The --patch-module entries are never searched if the boot loader's
1345   //       visibility boundary is limited to only searching the append entries.
1346   if (_patch_mod_entries != NULL && !search_append_only && !DumpSharedSpaces) {
1347     // Find the module in the boot loader's module entry table
1348     PackageEntry* pkg_entry = get_package_entry(class_name, ClassLoaderData::the_null_class_loader_data(), THREAD);
1349     ModuleEntry* mod_entry = (pkg_entry != NULL) ? pkg_entry->module() : NULL;
1350 
1351     // If the module system has not defined java.base yet, then
1352     // classes loaded are assumed to be defined to java.base.
1353     // When java.base is eventually defined by the module system,
1354     // all packages of classes that have been previously loaded
1355     // are verified in ModuleEntryTable::verify_javabase_packages().
1356     if (!Universe::is_module_initialized() &&
1357         !ModuleEntryTable::javabase_defined() &&
1358         mod_entry == NULL) {
1359       mod_entry = ModuleEntryTable::javabase_module();
1360     }
1361 
1362     // The module must be a named module
1363     if (mod_entry != NULL && mod_entry->is_named()) {
1364       int num_of_entries = _patch_mod_entries->length();
1365       const Symbol* class_module_name = mod_entry->name();
1366 
1367       // Loop through all the patch_mod entries looking for module
1368       for (int i = 0; i < num_of_entries; i++) {
1369         ModuleClassPathList* module_cpl = _patch_mod_entries->at(i);
1370         Symbol* module_cpl_name = module_cpl->module_name();
1371 
1372         if (module_cpl_name->fast_compare(class_module_name) == 0) {
1373           // Class' module has been located, attempt to load
1374           // the class from the module's ClassPathEntry list.
1375           e = module_cpl->module_first_entry();
1376           while (e != NULL) {
1377             stream = e->open_stream(file_name, CHECK_NULL);
1378             // No context.check is required since both CDS
1379             // and AppCDS are turned off if --patch-module is specified.
1380             if (NULL != stream) {
1381               break;
1382             }
1383             e = e->next();
1384           }
1385           // If the module was located in the patch_mod entries, break out
1386           // even if the class was not located successfully from that module's
1387           // ClassPathEntry list. There will not be another valid entry for
1388           // that module in the _patch_mod_entries array.
1389           break;
1390         }
1391       }
1392     }
1393   }
1394 
1395   // Load Attempt #2: [exploded build | jimage]
1396   if (!search_append_only && (NULL == stream)) {
1397     e = _first_entry;
1398     while ((e != NULL) && (e != _first_append_entry)) {
1399       stream = e->open_stream(file_name, CHECK_NULL);
1400       if (!context.check(stream, classpath_index)) {
1401         return NULL;
1402       }
1403       if (NULL != stream) {
1404         break;
1405       }
1406       e = e->next();
1407       ++classpath_index;
1408     }


1581 jlong ClassLoader::class_link_time_ms() {
1582   return UsePerfData ?
1583     Management::ticks_to_ms(_perf_class_link_time->get_value()) : -1;
1584 }
1585 
1586 int ClassLoader::compute_Object_vtable() {
1587   // hardwired for JDK1.2 -- would need to duplicate class file parsing
1588   // code to determine actual value from file
1589   // Would be value '11' if finals were in vtable
1590   int JDK_1_2_Object_vtable_size = 5;
1591   return JDK_1_2_Object_vtable_size * vtableEntry::size();
1592 }
1593 
1594 
1595 void classLoader_init1() {
1596   ClassLoader::initialize();
1597 }
1598 
1599 // Complete the ClassPathEntry setup for the boot loader
1600 void classLoader_init2() {
1601   // Setup the list of module/path pairs for --patch-module processing
1602   // This must be done after the SymbolTable is created in order
1603   // to use fast_compare on module names instead of a string compare.
1604   if (Arguments::get_patch_mod_prefix() != NULL) {
1605     ClassLoader::setup_patch_mod_entries();
1606   }
1607 
1608   // Determine if this is an exploded build
1609   ClassLoader::set_has_jimage();
1610 }
1611 
1612 
1613 bool ClassLoader::get_canonical_path(const char* orig, char* out, int len) {
1614   assert(orig != NULL && out != NULL && len > 0, "bad arguments");
1615   if (CanonicalizeEntry != NULL) {
1616     JavaThread* THREAD = JavaThread::current();
1617     JNIEnv* env = THREAD->jni_environment();
1618     ResourceMark rm(THREAD);
1619 
1620     // os::native_path writes into orig_copy
1621     char* orig_copy = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, strlen(orig)+1);
1622     strcpy(orig_copy, orig);
1623     if ((CanonicalizeEntry)(env, os::native_path(orig_copy), out, len) < 0) {
1624       return false;
1625     }


1641   // Get module entry table
1642   ModuleEntryTable* null_cld_modules = null_cld->modules();
1643   if (null_cld_modules == NULL) {
1644     vm_exit_during_initialization("No ModuleEntryTable for the boot class loader");
1645   }
1646 
1647   {
1648     MutexLocker ml(Module_lock, THREAD);
1649     ModuleEntry* jb_module = null_cld_modules->locked_create_entry_or_null(Handle(NULL), vmSymbols::java_base(), NULL, NULL, null_cld);
1650     if (jb_module == NULL) {
1651       vm_exit_during_initialization("Unable to create ModuleEntry for java.base");
1652     }
1653     ModuleEntryTable::set_javabase_module(jb_module);
1654   }
1655 }
1656 
1657 void ClassLoader::set_has_jimage() {
1658   // Determine if this is an exploded build. When looking for
1659   // the jimage file, only search the piece of the boot
1660   // loader's boot class path which contains [exploded build | jimage].
1661   // Do not search the boot loader's patch-module entries or append path.
1662   ClassPathEntry* e = _first_entry;
1663   ClassPathEntry* last_e = _first_append_entry;
1664   while ((e != NULL) && (e != last_e)) {
1665     JImageFile *jimage = e->jimage();
1666     if (jimage != NULL && e->is_jrt()) {
1667       _has_jimage = true;
1668 #if INCLUDE_CDS
1669       ClassLoader::initialize_module_loader_map(jimage);
1670 #endif
1671       return;
1672     }
1673     e = e->next();
1674   }
1675 }
1676 
1677 #ifndef PRODUCT
1678 
1679 // CompileTheWorld
1680 //
1681 // Iterates over all class path entries and forces compilation of all methods


< prev index next >