< prev index next >

src/hotspot/share/memory/filemap.cpp

Print this page




 189   _shared_path_table = mapinfo->_shared_path_table;
 190   _shared_path_entry_size = mapinfo->_shared_path_entry_size;
 191 
 192   // The following fields are for sanity checks for whether this archive
 193   // will function correctly with this JVM and the bootclasspath it's
 194   // invoked with.
 195 
 196   // JVM version string ... changes on each build.
 197   get_header_version(_jvm_ident);
 198 
 199   ClassLoaderExt::finalize_shared_paths_misc_info();
 200   _app_class_paths_start_index = ClassLoaderExt::app_class_paths_start_index();
 201   _app_module_paths_start_index = ClassLoaderExt::app_module_paths_start_index();
 202 
 203   _verify_local = BytecodeVerificationLocal;
 204   _verify_remote = BytecodeVerificationRemote;
 205   _has_platform_or_app_classes = ClassLoaderExt::has_platform_or_app_classes();
 206 }
 207 
 208 void SharedClassPathEntry::init(const char* name, TRAPS) {

 209   _timestamp = 0;
 210   _filesize  = 0;
 211 
 212   struct stat st;
 213   if (os::stat(name, &st) == 0) {
 214     if ((st.st_mode & S_IFMT) == S_IFDIR) {
 215       _is_dir = true;
 216     } else {
 217       _is_dir = false;


 218       _timestamp = st.st_mtime;

 219       _filesize = st.st_size;
 220     }
 221   } else {
 222     // The file/dir must exist, or it would not have been added
 223     // into ClassLoader::classpath_entry().
 224     //
 225     // If we can't access a jar file in the boot path, then we can't
 226     // make assumptions about where classes get loaded from.
 227     FileMapInfo::fail_stop("Unable to open file %s.", name);
 228   }
 229 
 230   size_t len = strlen(name) + 1;
 231   _name = MetadataFactory::new_array<char>(ClassLoaderData::the_null_class_loader_data(), (int)len, THREAD);
 232   strcpy(_name->data(), name);
 233 }
 234 
 235 bool SharedClassPathEntry::validate(bool is_class_path) {
 236   assert(UseSharedSpaces, "runtime only");
 237 
 238   struct stat st;
 239   const char* name = this->name();



 240   bool ok = true;
 241   log_info(class, path)("checking shared classpath entry: %s", name);
 242   if (os::stat(name, &st) != 0 && is_class_path) {
 243     // If the archived module path entry does not exist at runtime, it is not fatal
 244     // (no need to invalid the shared archive) because the shared runtime visibility check
 245     // filters out any archived module classes that do not have a matching runtime
 246     // module path location.
 247     FileMapInfo::fail_continue("Required classpath entry does not exist: %s", name);
 248     ok = false;
 249   } else if (is_dir()) {
 250     if (!os::dir_is_empty(name)) {
 251       FileMapInfo::fail_continue("directory is not empty: %s", name);
 252       ok = false;
 253     }
 254   } else if (is_jar_or_bootimage()) {
 255     if (_timestamp != st.st_mtime ||
 256         _filesize != st.st_size) {
 257       ok = false;
 258       if (PrintSharedArchiveAndExit) {
 259         FileMapInfo::fail_continue(_timestamp != st.st_mtime ?
 260                                    "Timestamp mismatch" :
 261                                    "File size mismatch");
 262       } else {
 263         FileMapInfo::fail_continue("A jar/jimage file is not the one used while building"
 264                                    " the shared archive file: %s", name);
 265       }
 266     }
 267   }
 268   return ok;
 269 }
 270 
 271 void SharedClassPathEntry::metaspace_pointers_do(MetaspaceClosure* it) {
 272   it->push(&_name);
 273   it->push(&_manifest);
 274 }
 275 
 276 void FileMapInfo::allocate_shared_path_table() {
 277   assert(DumpSharedSpaces, "Sanity");
 278 
 279   Thread* THREAD = Thread::current();
 280   ClassLoaderData* loader_data = ClassLoaderData::the_null_class_loader_data();
 281   ClassPathEntry* jrt = ClassLoader::get_jrt_entry();
 282 
 283   assert(jrt != NULL,
 284          "No modular java runtime image present when allocating the CDS classpath entry table");
 285 




 189   _shared_path_table = mapinfo->_shared_path_table;
 190   _shared_path_entry_size = mapinfo->_shared_path_entry_size;
 191 
 192   // The following fields are for sanity checks for whether this archive
 193   // will function correctly with this JVM and the bootclasspath it's
 194   // invoked with.
 195 
 196   // JVM version string ... changes on each build.
 197   get_header_version(_jvm_ident);
 198 
 199   ClassLoaderExt::finalize_shared_paths_misc_info();
 200   _app_class_paths_start_index = ClassLoaderExt::app_class_paths_start_index();
 201   _app_module_paths_start_index = ClassLoaderExt::app_module_paths_start_index();
 202 
 203   _verify_local = BytecodeVerificationLocal;
 204   _verify_remote = BytecodeVerificationRemote;
 205   _has_platform_or_app_classes = ClassLoaderExt::has_platform_or_app_classes();
 206 }
 207 
 208 void SharedClassPathEntry::init(const char* name, TRAPS) {
 209   assert(DumpSharedSpaces, "dump time only");
 210   _timestamp = 0;
 211   _filesize  = 0;
 212 
 213   struct stat st;
 214   if (os::stat(name, &st) == 0) {
 215     if ((st.st_mode & S_IFMT) == S_IFDIR) {
 216       _is_dir = true;
 217     } else {
 218       _is_dir = false;
 219       // The timestamp of the modules_image is not checked at runtime.
 220       if (!ClassLoader::is_modules_image(name)) {
 221         _timestamp = st.st_mtime;
 222       }
 223       _filesize = st.st_size;
 224     }
 225   } else {
 226     // The file/dir must exist, or it would not have been added
 227     // into ClassLoader::classpath_entry().
 228     //
 229     // If we can't access a jar file in the boot path, then we can't
 230     // make assumptions about where classes get loaded from.
 231     FileMapInfo::fail_stop("Unable to open file %s.", name);
 232   }
 233 
 234   size_t len = strlen(name) + 1;
 235   _name = MetadataFactory::new_array<char>(ClassLoaderData::the_null_class_loader_data(), (int)len, THREAD);
 236   strcpy(_name->data(), name);
 237 }
 238 
 239 bool SharedClassPathEntry::validate(bool is_class_path) {
 240   assert(UseSharedSpaces, "runtime only");
 241 
 242   struct stat st;
 243   const char* name = this->name();
 244   if (ClassLoader::is_modules_image(name)) {
 245     name = ClassLoader::get_jrt_entry()->name(); // use the runtime modules_image path
 246   }
 247   bool ok = true;
 248   log_info(class, path)("checking shared classpath entry: %s", name);
 249   if (os::stat(name, &st) != 0 && is_class_path) {
 250     // If the archived module path entry does not exist at runtime, it is not fatal
 251     // (no need to invalid the shared archive) because the shared runtime visibility check
 252     // filters out any archived module classes that do not have a matching runtime
 253     // module path location.
 254     FileMapInfo::fail_continue("Required classpath entry does not exist: %s", name);
 255     ok = false;
 256   } else if (is_dir()) {
 257     if (!os::dir_is_empty(name)) {
 258       FileMapInfo::fail_continue("directory is not empty: %s", name);
 259       ok = false;
 260     }
 261   } else if ((has_timestamp() && _timestamp != st.st_mtime) ||

 262              _filesize != st.st_size) {
 263     ok = false;
 264     if (PrintSharedArchiveAndExit) {
 265       FileMapInfo::fail_continue(_timestamp != st.st_mtime ?
 266                                  "Timestamp mismatch" :
 267                                  "File size mismatch");
 268     } else {
 269       FileMapInfo::fail_continue("A jar file is not the one used while building"
 270                                  " the shared archive file: %s", name);

 271     }
 272   }
 273   return ok;
 274 }
 275 
 276 void SharedClassPathEntry::metaspace_pointers_do(MetaspaceClosure* it) {
 277   it->push(&_name);
 278   it->push(&_manifest);
 279 }
 280 
 281 void FileMapInfo::allocate_shared_path_table() {
 282   assert(DumpSharedSpaces, "Sanity");
 283 
 284   Thread* THREAD = Thread::current();
 285   ClassLoaderData* loader_data = ClassLoaderData::the_null_class_loader_data();
 286   ClassPathEntry* jrt = ClassLoader::get_jrt_entry();
 287 
 288   assert(jrt != NULL,
 289          "No modular java runtime image present when allocating the CDS classpath entry table");
 290 


< prev index next >