318 EXCEPTION_MARK;
319 SharedClassUtil::update_shared_classpath(acpe, ent, THREAD);
320 acpe = acpe->next();
321 i++;
322 }
323
324 // 3. module path
325 ClassPathEntry *mpe = ClassLoader::module_path_entries();
326 while (mpe != NULL) {
327 log_info(class, path)("add module path %s",mpe->name());
328 SharedClassPathEntry* ent = shared_path(i);
329 ent->init(mpe->name(), THREAD);
330 EXCEPTION_MARK;
331 SharedClassUtil::update_shared_classpath(mpe, ent, THREAD);
332 mpe = mpe->next();
333 i++;
334 }
335 assert(i == num_entries, "number of shared path entry mismatch");
336 }
337
338 bool FileMapInfo::validate_shared_path_table() {
339 _validating_shared_path_table = true;
340
341 _shared_path_table = _header->_shared_path_table;
342 _shared_path_entry_size = _header->_shared_path_entry_size;
343 _shared_path_table_size = _header->_shared_path_table_size;
344
345 // Note: _app_module_paths_start_index may not have a valid value if the UseAppCDS flag
346 // wasn't enabled during dump time. Therefore, we need to use the smaller of
347 // _shared_path_table_size and _app_module_paths_start_index for the _app_module_paths_start_index.
348 FileMapHeaderExt* header = (FileMapHeaderExt*)FileMapInfo::current_info()->header();
349 int module_paths_start_index = (header->_app_module_paths_start_index >= _shared_path_table_size) ?
350 _shared_path_table_size : header->_app_module_paths_start_index;
351
352 int count = _shared_path_table_size;
353
354 for (int i=0; i<count; i++) {
355 if (i < module_paths_start_index) {
356 if (shared_path(i)->validate()) {
357 log_info(class, path)("ok");
992 }
993
994 char* FileMapInfo::FileMapHeader::region_addr(int idx) {
995 if (MetaspaceShared::is_heap_region(idx)) {
996 return _space[idx]._used > 0 ?
997 (char*)((void*)CompressedOops::decode_not_null((narrowOop)_space[idx]._addr._offset)) : NULL;
998 } else {
999 return _space[idx]._addr._base;
1000 }
1001 }
1002
1003 int FileMapInfo::FileMapHeader::compute_crc() {
1004 char* header = data();
1005 // start computing from the field after _crc
1006 char* buf = (char*)&_crc + sizeof(int);
1007 size_t sz = data_size() - (buf - header);
1008 int crc = ClassLoader::crc32(0, buf, (jint)sz);
1009 return crc;
1010 }
1011
1012 bool FileMapInfo::FileMapHeader::validate() {
1013 if (VerifySharedSpaces && compute_crc() != _crc) {
1014 fail_continue("Header checksum verification failed.");
1015 return false;
1016 }
1017
1018 if (!Arguments::has_jimage()) {
1019 FileMapInfo::fail_continue("The shared archive file cannot be used with an exploded module build.");
1020 return false;
1021 }
1022
1023 if (_version != current_version()) {
1024 FileMapInfo::fail_continue("The shared archive file is the wrong version.");
1025 return false;
1026 }
1027 if (_magic != (int)0xf00baba2) {
1028 FileMapInfo::fail_continue("The shared archive file has a bad magic number.");
1029 return false;
1030 }
1031 char header_version[JVM_IDENT_MAX];
|
318 EXCEPTION_MARK;
319 SharedClassUtil::update_shared_classpath(acpe, ent, THREAD);
320 acpe = acpe->next();
321 i++;
322 }
323
324 // 3. module path
325 ClassPathEntry *mpe = ClassLoader::module_path_entries();
326 while (mpe != NULL) {
327 log_info(class, path)("add module path %s",mpe->name());
328 SharedClassPathEntry* ent = shared_path(i);
329 ent->init(mpe->name(), THREAD);
330 EXCEPTION_MARK;
331 SharedClassUtil::update_shared_classpath(mpe, ent, THREAD);
332 mpe = mpe->next();
333 i++;
334 }
335 assert(i == num_entries, "number of shared path entry mismatch");
336 }
337
338 // This function should only be called during run time with UseSharedSpaces enabled.
339 bool FileMapInfo::validate_shared_path_table() {
340 _validating_shared_path_table = true;
341
342 _shared_path_table = _header->_shared_path_table;
343 _shared_path_entry_size = _header->_shared_path_entry_size;
344 _shared_path_table_size = _header->_shared_path_table_size;
345
346 // Note: _app_module_paths_start_index may not have a valid value if the UseAppCDS flag
347 // wasn't enabled during dump time. Therefore, we need to use the smaller of
348 // _shared_path_table_size and _app_module_paths_start_index for the _app_module_paths_start_index.
349 FileMapHeaderExt* header = (FileMapHeaderExt*)FileMapInfo::current_info()->header();
350 int module_paths_start_index = (header->_app_module_paths_start_index >= _shared_path_table_size) ?
351 _shared_path_table_size : header->_app_module_paths_start_index;
352
353 int count = _shared_path_table_size;
354
355 for (int i=0; i<count; i++) {
356 if (i < module_paths_start_index) {
357 if (shared_path(i)->validate()) {
358 log_info(class, path)("ok");
993 }
994
995 char* FileMapInfo::FileMapHeader::region_addr(int idx) {
996 if (MetaspaceShared::is_heap_region(idx)) {
997 return _space[idx]._used > 0 ?
998 (char*)((void*)CompressedOops::decode_not_null((narrowOop)_space[idx]._addr._offset)) : NULL;
999 } else {
1000 return _space[idx]._addr._base;
1001 }
1002 }
1003
1004 int FileMapInfo::FileMapHeader::compute_crc() {
1005 char* header = data();
1006 // start computing from the field after _crc
1007 char* buf = (char*)&_crc + sizeof(int);
1008 size_t sz = data_size() - (buf - header);
1009 int crc = ClassLoader::crc32(0, buf, (jint)sz);
1010 return crc;
1011 }
1012
1013 // This function should only be called during run time with UseSharedSpaces enabled.
1014 bool FileMapInfo::FileMapHeader::validate() {
1015 if (VerifySharedSpaces && compute_crc() != _crc) {
1016 fail_continue("Header checksum verification failed.");
1017 return false;
1018 }
1019
1020 if (!Arguments::has_jimage()) {
1021 FileMapInfo::fail_continue("The shared archive file cannot be used with an exploded module build.");
1022 return false;
1023 }
1024
1025 if (_version != current_version()) {
1026 FileMapInfo::fail_continue("The shared archive file is the wrong version.");
1027 return false;
1028 }
1029 if (_magic != (int)0xf00baba2) {
1030 FileMapInfo::fail_continue("The shared archive file has a bad magic number.");
1031 return false;
1032 }
1033 char header_version[JVM_IDENT_MAX];
|