182 _narrow_oop_mode = Universe::narrow_oop_mode();
183 _narrow_oop_base = Universe::narrow_oop_base();
184 _narrow_oop_shift = Universe::narrow_oop_shift();
185 _max_heap_size = MaxHeapSize;
186 _narrow_klass_base = Universe::narrow_klass_base();
187 _narrow_klass_shift = Universe::narrow_klass_shift();
188 _shared_path_table_size = mapinfo->_shared_path_table_size;
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, bool is_modules_image, 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 _type = dir_entry;
217 } else {
218 // The timestamp of the modules_image is not checked at runtime.
219 if (is_modules_image) {
220 _type = modules_image_entry;
221 } else {
342
343 // 3. module path
344 ClassPathEntry *mpe = ClassLoader::module_path_entries();
345 while (mpe != NULL) {
346 log_info(class, path)("add module path %s",mpe->name());
347 SharedClassPathEntry* ent = shared_path(i);
348 ent->init(mpe->name(), false, THREAD);
349 EXCEPTION_MARK;
350 update_shared_classpath(mpe, ent, THREAD);
351 mpe = mpe->next();
352 i++;
353 }
354 assert(i == num_entries, "number of shared path entry mismatch");
355 }
356
357 void FileMapInfo::check_nonempty_dir_in_shared_path_table() {
358 assert(DumpSharedSpaces, "dump time only");
359
360 bool has_nonempty_dir = false;
361
362 int end = _shared_path_table_size;
363 if (!ClassLoaderExt::has_platform_or_app_classes()) {
364 // only check the boot path if no app class is loaded
365 end = ClassLoaderExt::app_class_paths_start_index();
366 }
367
368 for (int i = 0; i < end; i++) {
369 SharedClassPathEntry *e = shared_path(i);
370 if (e->is_dir()) {
371 const char* path = e->name();
372 if (!os::dir_is_empty(path)) {
373 tty->print_cr("Error: non-empty directory '%s'", path);
374 has_nonempty_dir = true;
375 }
376 }
377 }
378
379 if (has_nonempty_dir) {
380 ClassLoader::exit_with_path_failure("Cannot have non-empty directory in paths", NULL);
381 }
382 }
383
384 class ManifestStream: public ResourceObj {
385 private:
386 u1* _buffer_start; // Buffer bottom
387 u1* _buffer_end; // Buffer top (one past last element)
388 u1* _current; // Current buffer position
450 THREAD);
451 char* p = (char*)(buf->data());
452 memcpy(p, manifest, manifest_size);
453 ent->set_manifest(buf);
454 }
455 }
456 }
457 }
458
459
460 bool FileMapInfo::validate_shared_path_table() {
461 assert(UseSharedSpaces, "runtime only");
462
463 _validating_shared_path_table = true;
464 _shared_path_table = _header->_shared_path_table;
465 _shared_path_entry_size = _header->_shared_path_entry_size;
466 _shared_path_table_size = _header->_shared_path_table_size;
467
468 int module_paths_start_index = _header->_app_module_paths_start_index;
469
470 // If the shared archive contain app or platform classes, validate all entries
471 // in the shared path table. Otherwise, only validate the boot path entries (with
472 // entry index < _app_class_paths_start_index).
473 int count = _header->has_platform_or_app_classes() ?
474 _shared_path_table_size : _header->_app_class_paths_start_index;
475
476 for (int i=0; i<count; i++) {
477 if (i < module_paths_start_index) {
478 if (shared_path(i)->validate()) {
479 log_info(class, path)("ok");
480 }
481 } else if (i >= module_paths_start_index) {
482 if (shared_path(i)->validate(false /* not a class path entry */)) {
483 log_info(class, path)("ok");
484 }
485 } else if (!PrintSharedArchiveAndExit) {
486 _validating_shared_path_table = false;
487 _shared_path_table = NULL;
488 _shared_path_table_size = 0;
489 return false;
490 }
491 }
492
493 _validating_shared_path_table = false;
494 return true;
495 }
496
|
182 _narrow_oop_mode = Universe::narrow_oop_mode();
183 _narrow_oop_base = Universe::narrow_oop_base();
184 _narrow_oop_shift = Universe::narrow_oop_shift();
185 _max_heap_size = MaxHeapSize;
186 _narrow_klass_base = Universe::narrow_klass_base();
187 _narrow_klass_shift = Universe::narrow_klass_shift();
188 _shared_path_table_size = mapinfo->_shared_path_table_size;
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 _max_used_path_index = ClassLoaderExt::max_used_path_index();
203
204 _verify_local = BytecodeVerificationLocal;
205 _verify_remote = BytecodeVerificationRemote;
206 _has_platform_or_app_classes = ClassLoaderExt::has_platform_or_app_classes();
207 }
208
209 void SharedClassPathEntry::init(const char* name, bool is_modules_image, TRAPS) {
210 assert(DumpSharedSpaces, "dump time only");
211 _timestamp = 0;
212 _filesize = 0;
213
214 struct stat st;
215 if (os::stat(name, &st) == 0) {
216 if ((st.st_mode & S_IFMT) == S_IFDIR) {
217 _type = dir_entry;
218 } else {
219 // The timestamp of the modules_image is not checked at runtime.
220 if (is_modules_image) {
221 _type = modules_image_entry;
222 } else {
343
344 // 3. module path
345 ClassPathEntry *mpe = ClassLoader::module_path_entries();
346 while (mpe != NULL) {
347 log_info(class, path)("add module path %s",mpe->name());
348 SharedClassPathEntry* ent = shared_path(i);
349 ent->init(mpe->name(), false, THREAD);
350 EXCEPTION_MARK;
351 update_shared_classpath(mpe, ent, THREAD);
352 mpe = mpe->next();
353 i++;
354 }
355 assert(i == num_entries, "number of shared path entry mismatch");
356 }
357
358 void FileMapInfo::check_nonempty_dir_in_shared_path_table() {
359 assert(DumpSharedSpaces, "dump time only");
360
361 bool has_nonempty_dir = false;
362
363 int last = _shared_path_table_size - 1;
364 if (last > ClassLoaderExt::max_used_path_index()) {
365 // no need to check any path beyond max_used_path_index
366 last = ClassLoaderExt::max_used_path_index();
367 }
368
369 for (int i = 0; i <= last; i++) {
370 SharedClassPathEntry *e = shared_path(i);
371 if (e->is_dir()) {
372 const char* path = e->name();
373 if (!os::dir_is_empty(path)) {
374 tty->print_cr("Error: non-empty directory '%s'", path);
375 has_nonempty_dir = true;
376 }
377 }
378 }
379
380 if (has_nonempty_dir) {
381 ClassLoader::exit_with_path_failure("Cannot have non-empty directory in paths", NULL);
382 }
383 }
384
385 class ManifestStream: public ResourceObj {
386 private:
387 u1* _buffer_start; // Buffer bottom
388 u1* _buffer_end; // Buffer top (one past last element)
389 u1* _current; // Current buffer position
451 THREAD);
452 char* p = (char*)(buf->data());
453 memcpy(p, manifest, manifest_size);
454 ent->set_manifest(buf);
455 }
456 }
457 }
458 }
459
460
461 bool FileMapInfo::validate_shared_path_table() {
462 assert(UseSharedSpaces, "runtime only");
463
464 _validating_shared_path_table = true;
465 _shared_path_table = _header->_shared_path_table;
466 _shared_path_entry_size = _header->_shared_path_entry_size;
467 _shared_path_table_size = _header->_shared_path_table_size;
468
469 int module_paths_start_index = _header->_app_module_paths_start_index;
470
471 // validate the path entries up to the _max_used_path_index
472 for (int i=0; i < _header->_max_used_path_index + 1; i++) {
473 if (i < module_paths_start_index) {
474 if (shared_path(i)->validate()) {
475 log_info(class, path)("ok");
476 }
477 } else if (i >= module_paths_start_index) {
478 if (shared_path(i)->validate(false /* not a class path entry */)) {
479 log_info(class, path)("ok");
480 }
481 } else if (!PrintSharedArchiveAndExit) {
482 _validating_shared_path_table = false;
483 _shared_path_table = NULL;
484 _shared_path_table_size = 0;
485 return false;
486 }
487 }
488
489 _validating_shared_path_table = false;
490 return true;
491 }
492
|