hotspot/src/share/vm/memory/filemap.cpp
changeset 40013 943cf01a6b82
parent 38207 2ed792c9481d
child 40244 b3055c216762
equal deleted inserted replaced
40012:f69cfe79fe98 40013:943cf01a6b82
   197 
   197 
   198   ClassLoaderData* loader_data = ClassLoaderData::the_null_class_loader_data();
   198   ClassLoaderData* loader_data = ClassLoaderData::the_null_class_loader_data();
   199   size_t entry_size = SharedClassUtil::shared_class_path_entry_size();
   199   size_t entry_size = SharedClassUtil::shared_class_path_entry_size();
   200 
   200 
   201   for (int pass=0; pass<2; pass++) {
   201   for (int pass=0; pass<2; pass++) {
   202     ClassPathEntry *cpe = ClassLoader::classpath_entry(0);
   202 
   203 
   203     // Process the modular java runtime image first
   204     for (int cur_entry = 0 ; cpe != NULL; cpe = cpe->next(), cur_entry++) {
   204     ClassPathEntry* jrt_entry = ClassLoader::get_jrt_entry();
       
   205     assert(jrt_entry != NULL,
       
   206            "No modular java runtime image present when allocating the CDS classpath entry table");
       
   207     const char *name = jrt_entry->name();
       
   208     int name_bytes = (int)(strlen(name) + 1);
       
   209     if (pass == 0) {
       
   210       count++;
       
   211       bytes += (int)entry_size;
       
   212       bytes += name_bytes;
       
   213       log_info(class, path)("add main shared path for modular java runtime image %s", name);
       
   214     } else {
       
   215       // The java runtime image is always in slot 0 on the shared class path.
       
   216       SharedClassPathEntry* ent = shared_classpath(0);
       
   217       struct stat st;
       
   218       if (os::stat(name, &st) == 0) {
       
   219         ent->_timestamp = st.st_mtime;
       
   220         ent->_filesize = st.st_size;
       
   221       }
       
   222       if (ent->_filesize == 0) {
       
   223         // unknown
       
   224         ent->_filesize = -2;
       
   225       }
       
   226       ent->_name = strptr;
       
   227       assert(strptr + name_bytes <= strptr_max, "miscalculated buffer size");
       
   228       strncpy(strptr, name, (size_t)name_bytes); // name_bytes includes trailing 0.
       
   229       strptr += name_bytes;
       
   230     }
       
   231 
       
   232     // Walk the appended entries, which includes the entries added for the classpath.
       
   233     ClassPathEntry *cpe = ClassLoader::classpath_entry(1);
       
   234 
       
   235     // Since the java runtime image is always in slot 0 on the shared class path, the
       
   236     // appended entries are started at slot 1 immediately after.
       
   237     for (int cur_entry = 1 ; cpe != NULL; cpe = cpe->next(), cur_entry++) {
   205       const char *name = cpe->name();
   238       const char *name = cpe->name();
   206       int name_bytes = (int)(strlen(name) + 1);
   239       int name_bytes = (int)(strlen(name) + 1);
       
   240       assert(!cpe->is_jrt(), "A modular java runtime image is present on the list of appended entries");
   207 
   241 
   208       if (pass == 0) {
   242       if (pass == 0) {
   209         count ++;
   243         count ++;
   210         bytes += (int)entry_size;
   244         bytes += (int)entry_size;
   211         bytes += name_bytes;
   245         bytes += name_bytes;
   226           EXCEPTION_MARK; // The following call should never throw, but would exit VM on error.
   260           EXCEPTION_MARK; // The following call should never throw, but would exit VM on error.
   227           SharedClassUtil::update_shared_classpath(cpe, ent, st.st_mtime, st.st_size, THREAD);
   261           SharedClassUtil::update_shared_classpath(cpe, ent, st.st_mtime, st.st_size, THREAD);
   228         } else {
   262         } else {
   229           struct stat st;
   263           struct stat st;
   230           if (os::stat(name, &st) == 0) {
   264           if (os::stat(name, &st) == 0) {
   231             if (cpe->is_jrt()) {
   265             if ((st.st_mode & S_IFDIR) == S_IFDIR) {
   232               // it's the "modules" jimage
       
   233               ent->_timestamp = st.st_mtime;
       
   234               ent->_filesize = st.st_size;
       
   235             } else if ((st.st_mode & S_IFDIR) == S_IFDIR) {
       
   236               if (!os::dir_is_empty(name)) {
   266               if (!os::dir_is_empty(name)) {
   237                 ClassLoader::exit_with_path_failure(
   267                 ClassLoader::exit_with_path_failure(
   238                   "Cannot have non-empty directory in archived classpaths", name);
   268                   "Cannot have non-empty directory in archived classpaths", name);
   239               }
   269               }
   240               ent->_filesize = -1;
   270               ent->_filesize = -1;
   884   if (Arguments::get_xpatchprefix() != NULL) {
   914   if (Arguments::get_xpatchprefix() != NULL) {
   885     FileMapInfo::fail_continue("The shared archive file cannot be used with -Xpatch.");
   915     FileMapInfo::fail_continue("The shared archive file cannot be used with -Xpatch.");
   886     return false;
   916     return false;
   887   }
   917   }
   888 
   918 
       
   919   if (!Arguments::has_jimage()) {
       
   920     FileMapInfo::fail_continue("The shared archive file cannot be used with an exploded module build.");
       
   921     return false;
       
   922   }
       
   923 
   889   if (_version != current_version()) {
   924   if (_version != current_version()) {
   890     FileMapInfo::fail_continue("The shared archive file is the wrong version.");
   925     FileMapInfo::fail_continue("The shared archive file is the wrong version.");
   891     return false;
   926     return false;
   892   }
   927   }
   893   if (_magic != (int)0xf00baba2) {
   928   if (_magic != (int)0xf00baba2) {