src/share/vm/memory/filemap.cpp

Print this page




 200         bytes += name_bytes;
 201         if (TraceClassPaths || (TraceClassLoading && Verbose)) {
 202           tty->print_cr("[Add main shared path (%s) %s]", (cpe->is_jar_file() ? "jar" : "dir"), name);
 203         }
 204       } else {
 205         SharedClassPathEntry* ent = shared_classpath(cur_entry);
 206         if (cpe->is_jar_file()) {
 207           struct stat st;
 208           if (os::stat(name, &st) != 0) {
 209             // The file/dir must exist, or it would not have been added
 210             // into ClassLoader::classpath_entry().
 211             //
 212             // If we can't access a jar file in the boot path, then we can't
 213             // make assumptions about where classes get loaded from.
 214             FileMapInfo::fail_stop("Unable to open jar file %s.", name);
 215           }
 216 
 217           EXCEPTION_MARK; // The following call should never throw, but would exit VM on error.
 218           SharedClassUtil::update_shared_classpath(cpe, ent, st.st_mtime, st.st_size, THREAD);
 219         } else {
 220           ent->_filesize  = -1;

 221           if (!os::dir_is_empty(name)) {
 222             ClassLoader::exit_with_path_failure("Cannot have non-empty directory in archived classpaths", name);
 223           }




 224         }
 225         ent->_name = strptr;
 226         if (strptr + name_bytes <= strptr_max) {
 227           strncpy(strptr, name, (size_t)name_bytes); // name_bytes includes trailing 0.
 228           strptr += name_bytes;
 229         } else {
 230           assert(0, "miscalculated buffer size");
 231         }
 232       }
 233     }
 234 
 235     if (pass == 0) {
 236       EXCEPTION_MARK; // The following call should never throw, but would exit VM on error.
 237       Array<u8>* arr = MetadataFactory::new_array<u8>(loader_data, (bytes + 7)/8, THREAD);
 238       strptr = (char*)(arr->data());
 239       strptr_max = strptr + bytes;
 240       SharedClassPathEntry* table = (SharedClassPathEntry*)strptr;
 241       strptr += entry_size * count;
 242 
 243       _classpath_entry_table_size = count;


 254 
 255   _classpath_entry_table = _header->_classpath_entry_table;
 256   _classpath_entry_size = _header->_classpath_entry_size;
 257 
 258   for (int i=0; i<count; i++) {
 259     SharedClassPathEntry* ent = shared_classpath(i);
 260     struct stat st;
 261     const char* name = ent->_name;
 262     bool ok = true;
 263     if (TraceClassPaths || (TraceClassLoading && Verbose)) {
 264       tty->print_cr("[Checking shared classpath entry: %s]", name);
 265     }
 266     if (os::stat(name, &st) != 0) {
 267       fail_continue("Required classpath entry does not exist: %s", name);
 268       ok = false;
 269     } else if (ent->is_dir()) {
 270       if (!os::dir_is_empty(name)) {
 271         fail_continue("directory is not empty: %s", name);
 272         ok = false;
 273       }
 274     } else {
 275       if (ent->_timestamp != st.st_mtime ||
 276           ent->_filesize != st.st_size) {
 277         ok = false;
 278         if (PrintSharedArchiveAndExit) {
 279           fail_continue(ent->_timestamp != st.st_mtime ?
 280                         "Timestamp mismatch" :
 281                         "File size mismatch");
 282         } else {
 283           fail_continue("A jar file is not the one used while building"
 284                         " the shared archive file: %s", name);
 285         }
 286       }
 287     }
 288     if (ok) {
 289       if (TraceClassPaths || (TraceClassLoading && Verbose)) {
 290         tty->print_cr("[ok]");
 291       }
 292     } else if (!PrintSharedArchiveAndExit) {
 293       _validating_classpath_entry_table = false;
 294       return false;




 200         bytes += name_bytes;
 201         if (TraceClassPaths || (TraceClassLoading && Verbose)) {
 202           tty->print_cr("[Add main shared path (%s) %s]", (cpe->is_jar_file() ? "jar" : "dir"), name);
 203         }
 204       } else {
 205         SharedClassPathEntry* ent = shared_classpath(cur_entry);
 206         if (cpe->is_jar_file()) {
 207           struct stat st;
 208           if (os::stat(name, &st) != 0) {
 209             // The file/dir must exist, or it would not have been added
 210             // into ClassLoader::classpath_entry().
 211             //
 212             // If we can't access a jar file in the boot path, then we can't
 213             // make assumptions about where classes get loaded from.
 214             FileMapInfo::fail_stop("Unable to open jar file %s.", name);
 215           }
 216 
 217           EXCEPTION_MARK; // The following call should never throw, but would exit VM on error.
 218           SharedClassUtil::update_shared_classpath(cpe, ent, st.st_mtime, st.st_size, THREAD);
 219         } else {
 220           struct stat st;
 221           if ((os::stat(name, &st) == 0) && ((st.st_mode & S_IFDIR) == S_IFDIR)) {
 222             if (!os::dir_is_empty(name)) {
 223               ClassLoader::exit_with_path_failure("Cannot have non-empty directory in archived classpaths", name);
 224             }
 225             ent->_filesize = -1;
 226           } else {
 227             ent->_filesize = -2;
 228           }
 229         }
 230         ent->_name = strptr;
 231         if (strptr + name_bytes <= strptr_max) {
 232           strncpy(strptr, name, (size_t)name_bytes); // name_bytes includes trailing 0.
 233           strptr += name_bytes;
 234         } else {
 235           assert(0, "miscalculated buffer size");
 236         }
 237       }
 238     }
 239 
 240     if (pass == 0) {
 241       EXCEPTION_MARK; // The following call should never throw, but would exit VM on error.
 242       Array<u8>* arr = MetadataFactory::new_array<u8>(loader_data, (bytes + 7)/8, THREAD);
 243       strptr = (char*)(arr->data());
 244       strptr_max = strptr + bytes;
 245       SharedClassPathEntry* table = (SharedClassPathEntry*)strptr;
 246       strptr += entry_size * count;
 247 
 248       _classpath_entry_table_size = count;


 259 
 260   _classpath_entry_table = _header->_classpath_entry_table;
 261   _classpath_entry_size = _header->_classpath_entry_size;
 262 
 263   for (int i=0; i<count; i++) {
 264     SharedClassPathEntry* ent = shared_classpath(i);
 265     struct stat st;
 266     const char* name = ent->_name;
 267     bool ok = true;
 268     if (TraceClassPaths || (TraceClassLoading && Verbose)) {
 269       tty->print_cr("[Checking shared classpath entry: %s]", name);
 270     }
 271     if (os::stat(name, &st) != 0) {
 272       fail_continue("Required classpath entry does not exist: %s", name);
 273       ok = false;
 274     } else if (ent->is_dir()) {
 275       if (!os::dir_is_empty(name)) {
 276         fail_continue("directory is not empty: %s", name);
 277         ok = false;
 278       }
 279     } else if (ent->is_jar()) {
 280       if (ent->_timestamp != st.st_mtime ||
 281           ent->_filesize != st.st_size) {
 282         ok = false;
 283         if (PrintSharedArchiveAndExit) {
 284           fail_continue(ent->_timestamp != st.st_mtime ?
 285                         "Timestamp mismatch" :
 286                         "File size mismatch");
 287         } else {
 288           fail_continue("A jar file is not the one used while building"
 289                         " the shared archive file: %s", name);
 290         }
 291       }
 292     }
 293     if (ok) {
 294       if (TraceClassPaths || (TraceClassLoading && Verbose)) {
 295         tty->print_cr("[ok]");
 296       }
 297     } else if (!PrintSharedArchiveAndExit) {
 298       _validating_classpath_entry_table = false;
 299       return false;