< 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 
 245   // We need to validate the runtime modules image file size against the archived
 246   // size information, obtain the runtime modules image path. The recorded dump
 247   // time modules image path in the archive may be different from the runtime path
 248   // if the JDK image has beed moved after generating the archive.
 249   if (ClassLoader::is_modules_image(name)) {
 250     name = ClassLoader::get_jrt_entry()->name();
 251   }
 252 
 253   bool ok = true;
 254   log_info(class, path)("checking shared classpath entry: %s", name);
 255   if (os::stat(name, &st) != 0 && is_class_path) {
 256     // If the archived module path entry does not exist at runtime, it is not fatal
 257     // (no need to invalid the shared archive) because the shared runtime visibility check
 258     // filters out any archived module classes that do not have a matching runtime
 259     // module path location.
 260     FileMapInfo::fail_continue("Required classpath entry does not exist: %s", name);
 261     ok = false;
 262   } else if (is_dir()) {
 263     if (!os::dir_is_empty(name)) {
 264       FileMapInfo::fail_continue("directory is not empty: %s", name);
 265       ok = false;
 266     }
 267   } else if ((has_timestamp() && _timestamp != st.st_mtime) ||

 268              _filesize != st.st_size) {
 269     ok = false;
 270     if (PrintSharedArchiveAndExit) {
 271       FileMapInfo::fail_continue(_timestamp != st.st_mtime ?
 272                                  "Timestamp mismatch" :
 273                                  "File size mismatch");
 274     } else {
 275       FileMapInfo::fail_continue("A jar file is not the one used while building"
 276                                  " the shared archive file: %s", name);

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


< prev index next >